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

Merged
merged 8 commits into from
Mar 20, 2024

Conversation

jerelmiller
Copy link
Member

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.

Copy link

changeset-bot bot commented Mar 20, 2024

🦋 Changeset detected

Latest commit: 0827aba

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 Mar 20, 2024

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
Copy link
Member Author

/release:pr

Copy link
Contributor

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

npm i @apollo/client@0.0.0-pr-11713-20240320175257

Copy link

netlify bot commented Mar 20, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit 0827aba
🔍 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.

Copy link
Contributor

@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.

Love a one line fix alongside so much additional test coverage 🙌

@jerelmiller jerelmiller merged commit 642092c into main Mar 20, 2024
33 checks passed
@jerelmiller jerelmiller deleted the jerel/issue-11708-global-errorpolicy branch March 20, 2024 18:33
@github-actions github-actions bot mentioned this pull request Mar 20, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 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.

startTransition has no affect on refetch or fetchMore with errorPolicy: 'all'
2 participants