react-apollo icon indicating copy to clipboard operation
react-apollo copied to clipboard

`getDataFromTree` not working with apollo local state

Open lifeiscontent opened this issue 5 years ago • 14 comments

Relevant issue here: https://github.com/zeit/next.js/pull/8673#discussion_r323275265

during SSR apollo local state should be resolved because the client may have access to the local state resolvers / cache like it does in this example.

lifeiscontent avatar Sep 11 '19 18:09 lifeiscontent

Is there a workaround for this?

carlows avatar Sep 17 '19 22:09 carlows

@hwillson might know, but from what I've found currently, no.

lifeiscontent avatar Sep 17 '19 23:09 lifeiscontent

Phew I'm also suffering from this atm. Might just go back and downgrade.

lasseborly avatar Sep 18 '19 21:09 lasseborly

I have the same issue. I created a small repo based off on Nextjs' with-apollo example, and described the behaviour in this SO question: https://stackoverflow.com/questions/58174010/apolllo-client-state-preset-cache-does-not-work-on-server-side-render I do a cache-write with initial data when I init the apollo-client. However, this cache gets ignored by the SSR (first) render, where I get returned loading: true, data: undefined. Which triggers an error, because I want to destructure the data immediately. Second server render & client render show correct data.

The repo: https://github.com/rnacken/next-with-apollo-client-state-cache

rnacken avatar Oct 02 '19 09:10 rnacken

Experiencing same issue, any workaround to this? My project contains a lot of @client directive and facing this is a pure surprise, this should be mentioned in docs if @client doesn't work on SSR.

devops398 avatar Nov 26 '19 13:11 devops398

Just ran into this issue. This completely nullfies the benefit of using Apollo as a local state management solution.

niamleeson avatar Jan 03 '20 20:01 niamleeson

Would anyone here be able to provide a small, runnable reproduction? The repro provided in https://github.com/apollographql/react-apollo/issues/3486#issuecomment-537420370 is fixed by updating to 3.1.3, but it isn't related to the original issue here.

hwillson avatar Jan 07 '20 21:01 hwillson

ping @HaNdTriX do you still have that example available showcasing the bug we ran into in the next.js repo?

lifeiscontent avatar Jan 08 '20 00:01 lifeiscontent

I have the same issue. getDataFromTree calls render with empty apollo storage (but it's not)

PerminovEugene avatar Jan 10 '20 06:01 PerminovEugene

Anyone found any solution for this yet? Having the same issue with local state not being read during getDataFromTree

seankooner avatar Feb 12 '20 20:02 seankooner

@seankooner post a reproduction of your issue.

lifeiscontent avatar Feb 13 '20 22:02 lifeiscontent

Meanwhile the issue can be fixed using getMarkupFromTree inplace of getDataFromTree. Reference thread - https://github.com/apollographql/react-apollo/issues/3251

akshatnitd avatar Feb 18 '20 10:02 akshatnitd

Met same issue. Both getMarkupFromTree and getDataFromTree don't wait until all data is fetched. And, yes, I use await. But when I log Apollo's state returned by client.extract() and props of my Root component to console, Apollo-state is being logged first and after that I see log showing me that Root component has props.loading = true

ralexandr avatar Apr 12 '20 18:04 ralexandr

Found solution for me: I removed old react-apollo package from my project’s deps and somehow that has resolved my issue

ralexandr avatar Apr 14 '20 17:04 ralexandr