SSR with-apollo and query variable from cache issue. #NeedHelp #12078
Unanswered
NiestrojMateusz
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I have some issue when trying to use
@apollo/client: latest
withnext:latest
,useQuery
hooks and apollo cache.So step by step:
I use with-apollo HOC (from Next examples) in
_app.js
file.I initialize state and pass it to ApolloCache when creating an Apollo Client
In original project state is generated based on request headers, here I used some reproduction example;
In
_app.js
Component is wrapped by ConfigProvider which query the data from apollo cache in this way:Right after ConfigProvider ConfigConusmer pass the
config
to PostsProvider which use that config in another useQueryThe issue is when Next execute
getDataFromTree()
even when config is already in cacheuseQuery
in ConfigProvider always first returnloading: true
anddata: undefined
, that makes that PostProvider have corrupted variable and getDataFromTree throws an error. In the result all PostProvider query is called on client-side instead of server-side.Can someone explain that behavior for me? Why first traverse return undefined even when data is already in apollo cache? Is there a way to make it work?
here is a codesanbox example https://codesandbox.io/s/trusting-sinoussi-qw4qi
Beta Was this translation helpful? Give feedback.
All reactions