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

Avoid adding QueryPromise when skip is true on SSR #7310

Merged

Conversation

izumin5210
Copy link
Contributor

Fixing #6342

When skip is set to true on SSR, useQuery skips a network request. But firing renderToString.

Checklist:

only small bugfix

  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

@apollo-cla
Copy link

@izumin5210: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Apollo Contributor License Agreement here: https://contribute.apollographql.com/

@izumin5210
Copy link
Contributor Author

Signed ✅

Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@izumin5210 This makes sense to me, and thanks for adding a regression test. Sorry to keep you waiting!

@benjamn benjamn force-pushed the izumin5210/see-skip-option-on-ssr branch from eaa2886 to 4b9145a Compare November 18, 2020 21:27
@benjamn benjamn changed the base branch from main to release-3.3 November 18, 2020 21:27
@benjamn benjamn merged commit 5184845 into apollographql:release-3.3 Nov 18, 2020
@izumin5210 izumin5210 deleted the izumin5210/see-skip-option-on-ssr branch November 19, 2020 00:41
rgrove added a commit to rgrove/apollo-client that referenced this pull request Jan 11, 2021
PR apollographql#7310 introduced a regression that caused skipped SSR queries to
always set `loading` to `true`, which doesn't match the behavior of
`useQuery()` on the client and can result in hydration mismatches.

The problem is that `skip: true` was being treated as equivalent to
`ssr: false`, but they're not actually equivalent. I think the correct
solution is to let `this.getQueryResult()` provide a suitable result
when `skip` is truthy, which ensures that skipped SSR queries will get
the same result as skipped non-SSR queries.

Fixes apollographql#7380
benjamn added a commit that referenced this pull request Jan 14, 2021
PR #7310 introduced a regression that caused skipped SSR queries to
always set `loading` to `true`, which doesn't match the behavior of
`useQuery()` on the client and can result in hydration mismatches.

The problem is that `skip: true` was being treated as equivalent to
`ssr: false`, but they're not actually equivalent. I think the correct
solution is to let `this.getQueryResult()` provide a suitable result
when `skip` is truthy, which ensures that skipped SSR queries will get
the same result as skipped non-SSR queries.

Fixes #7380

Co-authored-by: Ben Newman <ben@apollographql.com>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants