Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrating from apollo-link-state #1183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mitjade
Copy link
Collaborator

@mitjade mitjade commented Jan 15, 2020

What's the problem this PR addresses?
I am trying to migrate from apollo-link-state, to fix default state not being set on ssr.

When this kit migrated to apollo-client 3.0 (#1134), default state was not set on ssr. Workaround for this was to set it in code and pass it to components manualy -> https://github.com/sysgears/apollo-universal-starter-kit/pull/1134/files#diff-1c960d0cc9e1d13dca0e9950e18e5f4eR25.

Apollo docs, state that apollo-link-state is no longer needed and can be removed like this:
https://www.apollographql.com/docs/react/v2.5/essentials/local-state/#migrating-from-apollo-link-state

It also states that defaults are no longer supported and cache.writeData should be used to set it.

How did you fix it?
I followed the migration guide and removed withClientState and called cache.writeData , to set default data, but it does not seem to work. Now even when code gets regenerated on client side, local state is not working.

I console.log props.filter on /users route, to test this out.

@larixer Could you please take a look what I am doing wrong and if you have any suggestions how to fix this?

@mitjade
Copy link
Collaborator Author

mitjade commented Jan 22, 2020

I think the problem is described here: apollographql/react-apollo#3338.

I guess I need to rewrite my code to handle the initial loading: true state in ssr queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant