[SOLVED] Strange behaviour with NextJS/Apollo-GraphQL in production

Hello, I’m developing a NextJS app with Apollo as GraphQL client to call my Squidex app client. During the development on localhost and trying it in production environment too, everything works fine.
Today I’ve just deployed it on Zeit.co, then on Heroku and seems that both of them cannot establish a communication with Squidex someway.
The strange thing is that if I point to the live URL (currently https://lucacattide.dev - https://lucacattide.herokuapp.com), I don’t receive any CORS, or maybe any kind of exception about environment, domains or anything else. The only one is being thrown on both the platforms logs is this one:

Error while running getDataFromTree TypeError: Cannot read property ‘queryPageContents’ of undefined

Which is related to this code snippet - responsible to initialize the JSON response to be used to populate the app:

// Apollo query Hook
const {loading, error, data} = useQuery(PAGE_QUERY);
// Here my app data should be initialized as query result, then "pages" it being used as populating array on following code
const pages = data.queryPageContents;

I’ve already tried to change Squidex client permissions to an higher level - from reader to developer - but It seems to not be related to this kind of issue.
On front-end this is being receipt as a 500 error, and if I inspect the page I don’t see the API call to Squidex client neither - It’s like something is preventing it to be called or blocking it to be executed somehow.
This is quite strange because as said on localhost this not happens but on a live environment it is (independently from the platform I’m using).

Do you have idea on what I’m missing? Any kind of tip and/or suggestion it’ll be appreciated.

Thanks in advance for your support.

Have you checked the logs?

  • Your Heroku Logs
  • Squidex logs
  • Browser logs?

Can you dump the responses somehow? I don’t know what is going on, it is just a blackbox for me right now.

Yes, here they go.

These are the browser logs on localhost, both dev/production mode. They look the same:


Data is being returned as expected.

On hosting, Heroku logs returning me the previously quoted message. If I inspect the hosting production environment via Apollo DevTools, schema is returned in the right way, but the actual query doesn’t have be executed:

But by inspecting via browser, I notice this difference on the logs:

Basically, the same query that runs well on localhost production mode, is returning a total different level of encapsulated response on hosting production.
Now, because I’ve already did the Squidex client rights test - by changing from reader to developer and so on - am I wrong in some configuration or what?
I’m currently trying to check somewhere about Heroku docs but I don’t found nothing for now.

Is there some caching involved in heroku or cloudflare?

Yes, I purged the hosting repo cache and the Node modules dependencies cache too, then I deployed again. But it still the same.


Just get it that GraphQL introspection is enabled, so it’s returning me the entire __schema root, instead of my data.
Anyway, by googling around I’ve found this package that allows you to disable it: graphql-disable-introspection. It must be enabled on server-side. I don’t know if it could help, but I’m still not getting how is this happening.

You have a custom Squidex instance, right? If something gets cached there it could potentially cause this error.

If you mean that I’m on a Squidex standalone installation (i.e. Docker), no I’m not. I’m connecting to Squidex cloud via a production client that I created and set to Reader as data right. But as I mentioned, in the first place i was convinced that it could be related to a rights issue, but after various tries I excluded that reason.

You are right, I could have seen it in your screenshots. Can you send me your app?

Now you can reach it at https://lucacattide.herokuapp.com

If you need to inspect sources, I can give you a temporary Github access to it.

Hello, any news about this?

Not yet, but access to the source code would be good I think.

Thanks, I just sent you GitHub invitation.

Thanks @Sebastian, your suggestion was fair. Now it works perfectly.
Thank you so much for your help.

You are welcome. I hope for free advertisement and some business plans user :wink:

It has been solved. There was a bug in the client code.