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

(next) - Prevent restoring SSR data when client has been reset #1715

Merged
merged 3 commits into from
Jul 6, 2021

Conversation

Biboswan
Copy link
Contributor

@Biboswan Biboswan commented Jun 9, 2021

Resolves #1714

This aims to fix two things

  1. When we first visit a page and later do resetUrqlClient. We do end up using a new client because urqlClient prop was set to null. But due to ssr.restoreData(urqlServerState) Results are fetched from old ssr cache and network isn't called.
  2. When we navigate to a new page (client side rendered) urqlClient prop is not null and that is the client we use. Now if you call resetUrqlClient, we don't get a new client because of existing urqlClient prop value. if (urqlClient) return urqlClient

@changeset-bot
Copy link

changeset-bot bot commented Jun 9, 2021

🦋 Changeset detected

Latest commit: e8fa29b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
next-urql Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Biboswan Biboswan changed the title Use latest client and don't use old ssr cache on resetUrqlClient (next-urql) - Use latest client and don't use old ssr cache on resetUrqlClient Jun 11, 2021
@JoviDeCroock
Copy link
Collaborator

JoviDeCroock commented Jun 18, 2021

I've been a bit on and off about this particular issue as it introduces a very indeterministic scenario, when we have different SSG'ed pages on our web-application when reset is called these won't be able to restore anymore. Afaik server-side injecting authorized state is not really advised so logging off and on by resetting the urql-client generally won't pull data from __NEXT_DATA__ if this is done. I guess when we talk about pure SSR applications without a very strict CDN there will be cases where users store authorized state in this injected part, I would personally advise clearing the authorized state from the dom-node that injects this rather than fully clearing the client. I wouldn't incorporate this in next-urql for the reason that a lot of applications could see unexpected results.

@kitten kitten changed the title (next-urql) - Use latest client and don't use old ssr cache on resetUrqlClient (next) - Prevent restoring SSR data when client has been reset Jul 6, 2021
@kitten kitten merged commit 53eff85 into urql-graphql:main Jul 6, 2021
@urql-ci urql-ci mentioned this pull request Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants