0
votes

everyone!

I use Next.js and getStaticProps function in order to fetch data on server side. And it fetches data well but with one exception.

I receive error Can't find field '<field>' on ROOT_QUERY object after executing function client.readQuery({ query: QUERY }).

And when I looked in client.cache.data.data on client side I noticed that field that I tried to fetch from cache and which was fatched on server side is not in ROOT_QUERY but near it(red color).

And in ROOT_QUERY I can see only field which was fetched on client side(green color). enter image description here

But on server side there are all fields in ROOT_QUERYenter image description here.

Of course I can pass fetched data via props and use them but I would like to use cache instead.

If anyone faced with this I would like to receive an advice how to handle this. Thanks.

Here is my apollo-client configuration.

1

1 Answers

0
votes

Sorry, I missed initialApolloState in _app.tsx.

enter image description here

And in getStaticProps()

enter image description here