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

Fix issue where a network request is made when using skip/skipToken with useSuspenseQuery in strict mode #11769

Merged
merged 7 commits into from
Apr 10, 2024

Conversation

jerelmiller
Copy link
Member

Fixes #11768

#11738 made it possible to dispose of the queryRef synchronously in our suspense hooks which released in 3.9.10. Unfortunately this caused a regression with strict mode where a network request was actually made. This change ensures that standby is properly handled in the queryRef reinitialize function.

NOTE: This only seemed to affect useSuspenseQuery. I've added tests for useBackgroundQuery as well to ensure we don't have future regressions, but the bug didn't seem to exhibit itself in this hook.

Copy link

changeset-bot bot commented Apr 8, 2024

🦋 Changeset detected

Latest commit: 8bbde98

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

This PR includes changesets to release 1 package
Name Type
@apollo/client 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

Copy link
Contributor

github-actions bot commented Apr 8, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 38.45 KB (+0.02% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 46.28 KB (+0.02% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 43.84 KB (+0.03% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 33.96 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 31.87 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.23 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.22 KB (0%)
import { useQuery } from "dist/react/index.js" 5.27 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.35 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 5.5 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.58 KB (0%)
import { useMutation } from "dist/react/index.js" 3.51 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.73 KB (0%)
import { useSubscription } from "dist/react/index.js" 3.19 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 2.38 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 5.44 KB (-0.04% 🔽)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.1 KB (-0.05% 🔽)
import { useBackgroundQuery } from "dist/react/index.js" 4.92 KB (-0.06% 🔽)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.57 KB (-0.06% 🔽)
import { useLoadableQuery } from "dist/react/index.js" 5.03 KB (0%)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.69 KB (0%)
import { useReadQuery } from "dist/react/index.js" 3.17 KB (+0.13% 🔺)
import { useReadQuery } from "dist/react/index.js" (production) 3.12 KB (+0.07% 🔺)
import { useFragment } from "dist/react/index.js" 2.27 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.22 KB (0%)


try {
if (originalFetchPolicy !== "no-cache") {
if (avoidNetworkRequests) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I swapped the order of these if statements as the positive connotation is always easier for my brain to comprehend when there is an else included

Copy link

netlify bot commented Apr 8, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit debb4ba
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/66145a344cdaaa0008ae0e9a
😎 Deploy Preview https://deploy-preview-11769--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 8, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 8bbde98
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/661618f457ded40007a7d4d1
😎 Deploy Preview https://deploy-preview-11769--apollo-client-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

Good catch!

@github-actions github-actions bot added the auto-cleanup 🤖 label Apr 9, 2024
Copy link
Member

@alessbell alessbell left a comment

Choose a reason for hiding this comment

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

💯

@jerelmiller jerelmiller changed the base branch from main to release-3.10 April 9, 2024 19:55
@jerelmiller jerelmiller changed the base branch from release-3.10 to main April 9, 2024 23:32
@jerelmiller jerelmiller requested a review from a team as a code owner April 9, 2024 23:32
@jerelmiller jerelmiller changed the base branch from main to release-3.10 April 9, 2024 23:33
@jerelmiller jerelmiller changed the base branch from release-3.10 to main April 10, 2024 04:43
@jerelmiller jerelmiller merged commit 04132af into main Apr 10, 2024
45 checks passed
@jerelmiller jerelmiller deleted the jerel/fix-usq-skip-strict branch April 10, 2024 04:56
@github-actions github-actions bot mentioned this pull request Apr 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

useSuspenseQuery with skipToken still issues network request
3 participants