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

Add support for skip option to useSuspenseQuery and useBackgroundQuery #10940

Merged
merged 33 commits into from
Jun 15, 2023

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Jun 2, 2023

Closes #10532

Adds support for the skip option to useSuspenseQuery and useBackgroundQuery.

Checklist:

  • If this PR contains changes to the library itself (not necessary for e.g. docs updates), please include a changeset (see CONTRIBUTING.md)
  • 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

@changeset-bot
Copy link

changeset-bot bot commented Jun 2, 2023

🦋 Changeset detected

Latest commit: 322f355

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
Copy link
Contributor

github-actions bot commented Jun 6, 2023

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 36.78 KB (+0.58% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 43.19 KB (+0.5% 🔺)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 32.49 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.3 KB (0%)
import { useQuery } from "dist/react/index.js" 4.34 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 4.66 KB (0%)
import { useMutation } from "dist/react/index.js" 2.57 KB (0%)
import { useSubscription } from "dist/react/index.js" 2.34 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 3.71 KB (+7.39% 🔺)
import { useBackgroundQuery } from "dist/react/index.js" 3 KB (+4% 🔺)
import { useReadQuery } from "dist/react/index.js" 1.81 KB (+9.73% 🔺)
import { useFragment } from "dist/react/index.js" 2.12 KB (0%)

@jerelmiller
Copy link
Member Author

This PR is ready to go except for the types. I will need the changes from #10951 to ensure the types are correct.

@jerelmiller jerelmiller marked this pull request as ready for review June 8, 2023 23:52
@jerelmiller jerelmiller requested a review from alessbell June 8, 2023 23:52
@alessbell
Copy link
Contributor

alessbell commented Jun 9, 2023

I will need the changes from #10951 to ensure the types are correct.

Just merged #10951 and merged the release branch back into this one to kick off the tests again. Is this one ready for review now?

Edit: just saw we'll need to adjust the types for useBackgroundQuery but otherwise looks like I can start 👍

@jerelmiller
Copy link
Member Author

@alessbell this PR should be ready to go now. I'd like to take a pass at refactoring in general in a future PR so if you see opportunities for consolidation/refactoring, feel free to point them out. Thanks!

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.

It's great to have this feature parity with useQuery finally in place in the new Suspense hooks 🎉🎉

Re: any refactoring we may want to do between useBackgroundQuery/useSuspenseQuery - since there's a small amount of duplication, I'm good with leaving them as they are for now until it becomes a bit clearer how they can/should share code (if at all). 🚀

expectTypeOf(explicit).toEqualTypeOf<VariablesCaseData | undefined>();
expectTypeOf(explicit).not.toEqualTypeOf<VariablesCaseData>();

// TypeScript is too smart and using a `const` or `let` boolean variable
Copy link
Contributor

Choose a reason for hiding this comment

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

Good to know!

}

// Assign the updated fetch policy after our validation since `standby` is
// not a supported fetch policy on its own without the use of `skip`.
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jerelmiller jerelmiller merged commit 1d38f12 into release-3.8 Jun 15, 2023
@jerelmiller jerelmiller deleted the add-skip-support branch June 15, 2023 21:12
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 16, 2023
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.

2 participants