apollographql / apollo-client

:rocket:  A fully-featured, production ready caching GraphQL client for every UI framework and GraphQL server.
https://apollographql.com/client
MIT License
19.38k stars 2.66k forks source link

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

Closed jerelmiller closed 7 months ago

jerelmiller commented 7 months ago

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.

changeset-bot[bot] commented 7 months ago

🦋 Changeset detected

Latest commit: 8bbde98973c9f3b53f860d809a6c20c44f086ae2

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

github-actions[bot] commented 7 months ago

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%)
netlify[bot] commented 7 months ago

Deploy Preview for apollo-client-docs ready!

Name Link
Latest commit debb4baf6943fb4224f807d2761a6d8da5133187
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.

netlify[bot] commented 7 months ago

Deploy Preview for apollo-client-docs ready!

Name Link
Latest commit 8bbde98973c9f3b53f860d809a6c20c44f086ae2
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.