0

I have a GraphQL to fill in my menu. When I use jss start:connected it works just fine, but when I deploy (jss deploy app) and get it from the server it's empty.

I have been digging a bit into what's happening and it seems like the cache is not filled out correctly. In the source I get from the server the script tag _jss_state__ is filled out with:

"APOLLO_STATE":{"ROOT_QUERY":{"item({\"path\":\"\u002Fsitecore\u002Fcontent\u002Fxlbygg\u002Fhome\"})":null,"item({})":null}}}

As you can see the item for both paths are null. The item should have been filled out something like this:

[{"data":{"item":{"name":"home","displayName":"home","pageTitle":{"value":"","__typename":"TextField"},"__typename":"AppRoute","children":[{"name":"generelt","id":"C9184E8651DC5B8889978E60C856AEC3","hideInMenu":...

I have now reset the cache in GraphQlClientFactory.js

export default function (endpoint, ssr, initialCacheState) {
    initialCacheState = {
        ROOT_QUERY:
        {

        }
    };

And at least the client gets data, but I thought the point of SSR was to fill in this information on the server side?

How do I get the ROOT_QUERY populated correctly on the server side?

Edit: I have modified one of my queries to contain the content from query.graphql from the sample project and then it works. But if I switch out the content of the file with my own query, it stops working. Is this a bug or something I don't understand?

0

The problem was language, this is not defined in the default [site].config of the react app. Turns out integrated mode defaulted to en, while the test url (.no domain) defaulted to nb-NO. After setting language="nb-NO" on the site in the config file. Everything started working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.