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 setting `defaultOptions` would sometimes break `startTransition` for suspense hooks #11713

Closed jerelmiller closed 8 months ago

jerelmiller commented 8 months ago

Fixes #11708

Fixes an issue where setting a default watchQuery option in defaultOptions on the ApolloClient constructor had the potential to break startTransition. When using a default option, the queryRef.didChangeOptions check would always return true if the same option were not also passed to the hook directly. Because this returned true, we'd use a different promise than what React expected for the transition, which ended up showing the Suspense fallback instead of keeping the current UI on screen.

This check now takes into account whether the option is defined in the hook options before checking to see if the value changed or not.

changeset-bot[bot] commented 8 months ago

🦋 Changeset detected

Latest commit: 0827aba26ea4f00d051083b08606836d84e6ca11

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 8 months ago

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 38.36 KB (+0.02% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 46.18 KB (+0.02% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 43.74 KB (+0.01% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 33.95 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.26 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.37 KB (+0.11% 🔺)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.04 KB (+0.13% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" 4.84 KB (+0.11% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.5 KB (+0.17% 🔺)
import { useLoadableQuery } from "dist/react/index.js" 4.98 KB (+0.06% 🔺)
import { useLoadableQuery } from "dist/react/index.js" (production) 3.64 KB (+0.14% 🔺)
import { useReadQuery } from "dist/react/index.js" 3.13 KB (+0.16% 🔺)
import { useReadQuery } from "dist/react/index.js" (production) 3.07 KB (+0.16% 🔺)
import { useFragment } from "dist/react/index.js" 2.27 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.22 KB (0%)
jerelmiller commented 8 months ago

/release:pr

github-actions[bot] commented 8 months ago

A new release has been made for this PR. You can install it with:

npm i @apollo/client@0.0.0-pr-11713-20240320175257
netlify[bot] commented 8 months ago

Deploy Preview for apollo-client-docs ready!

Name Link
Latest commit 0827aba26ea4f00d051083b08606836d84e6ca11
Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/65fb252db0d4fa0008c5c48b
Deploy Preview https://deploy-preview-11713--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.