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

Document new React APIs in 3.9 - Part 1 of 2 #11512

Merged
merged 65 commits into from
Jan 29, 2024

Conversation

jerelmiller
Copy link
Member

@jerelmiller jerelmiller commented Jan 22, 2024

Closes #11491
Closes #11493
Closes #11494

Adds new sections to our suspense docs for useLoadableQuery, createQueryPreloader, and useQueryRefHandlers.

NOTE: This only addresses the "guide" part of the documentation. A followup PR to ensure the API documentation for the hook is available (options, return values, etc.). This may require edits to code and will fall in line with the changes in #11381

@jerelmiller jerelmiller requested a review from a team as a code owner January 22, 2024 22:47
Copy link

changeset-bot bot commented Jan 22, 2024

⚠️ No Changeset found

Latest commit: c236219

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Jan 22, 2024

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 37.04 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 43.5 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 41.99 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 32.53 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 31.22 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.22 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.2 KB (0%)
import { useQuery } from "dist/react/index.js" 4.27 KB (0%)
import { useQuery } from "dist/react/index.js" (production) 4.08 KB (0%)
import { useLazyQuery } from "dist/react/index.js" 4.58 KB (0%)
import { useLazyQuery } from "dist/react/index.js" (production) 4.39 KB (0%)
import { useMutation } from "dist/react/index.js" 2.55 KB (0%)
import { useMutation } from "dist/react/index.js" (production) 2.53 KB (0%)
import { useSubscription } from "dist/react/index.js" 2.23 KB (0%)
import { useSubscription } from "dist/react/index.js" (production) 2.19 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" 4.61 KB (0%)
import { useSuspenseQuery } from "dist/react/index.js" (production) 4.05 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" 4.13 KB (0%)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.55 KB (0%)
import { useReadQuery } from "dist/react/index.js" 2.99 KB (0%)
import { useReadQuery } from "dist/react/index.js" (production) 2.93 KB (0%)
import { useFragment } from "dist/react/index.js" 2.17 KB (0%)
import { useFragment } from "dist/react/index.js" (production) 2.11 KB (0%)

@@ -433,6 +433,58 @@ When the network request for `GET_DOG_QUERY` completes, the `Dog` component unsu

The `useBackgroundQuery` hook used in a parent component is responsible for kicking off fetches, but doesn't deal with reading or rendering data. This is delegated to the `useReadQuery` hook used in a child component. This separation of concerns provides a nice performance benefit because cache updates are observed by `useReadQuery` and re-render only the child component. You may find this as a useful tool to optimize your component structure to avoid unnecessarily re-rendering parent components when cache data changes.

<MinVersion version="3.9.0">

### Querying in response to user interaction
Copy link
Member Author

Choose a reason for hiding this comment

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

Another point of feedback: Does this section include enough information?

Some other things we could talk about if we want to provide additional info:

  • The hook does not take a variables option and instead variables are passed to the loadQuery function.
  • The hook exports a reset function that when called, sets the queryRef back to null

This section is also provided right before pagination/refetching, which uses useBackgroundQuery as the example. Should this be moved afterward? Feedback welcome!

@jerelmiller jerelmiller changed the base branch from main to 3.9-docs January 22, 2024 23:05
@jerelmiller jerelmiller changed the title Document useLoadableQuery - Part 1 of 2 Document new React APIs in 3.9 - Part 1 of 2 Jan 23, 2024
@jerelmiller jerelmiller force-pushed the jerel/document-loadable-query branch 3 times, most recently from 474b6b4 to 9533f3b Compare January 23, 2024 00:56
@jerelmiller jerelmiller force-pushed the jerel/document-loadable-query branch from 9533f3b to fe9674a Compare January 23, 2024 00:58
@jerelmiller jerelmiller linked an issue Jan 23, 2024 that may be closed by this pull request
@jerelmiller jerelmiller force-pushed the jerel/document-loadable-query branch from 329c4b5 to fefd6a4 Compare January 23, 2024 01:23
Copy link

netlify bot commented Jan 23, 2024

Deploy Preview for apollo-client-docs ready!

Name Link
🔨 Latest commit c236219
🔍 Latest deploy log https://app.netlify.com/sites/apollo-client-docs/deploys/65b442d9342b70000819b40d
😎 Deploy Preview https://deploy-preview-11512--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.

Excited to get these merged 🔥 Added some comments where I'm thinking aloud but overall everything is easy to follow and the examples are a natural extension of the 3.8 docs 🎉 🎉

docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
docs/source/data/suspense.mdx Outdated Show resolved Hide resolved
Let's update our last example back to `useBackgroundQuery` and get the `refetch` function from the `useQueryRefHandlers` hook in the `Dog` component.

```tsx {15,16,18-22,30}
function App() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to throw the rest of these in the codesandbox too 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah yes thank you! Was on my todo, but hadn't got to it yet!

@github-actions github-actions bot added the auto-cleanup 🤖 label Jan 26, 2024
jerelmiller and others added 20 commits January 26, 2024 15:28
Co-authored-by: Alessia Bellisario <[email protected]>
Co-authored-by: Alessia Bellisario <[email protected]>
Co-authored-by: Alessia Bellisario <[email protected]>
Co-authored-by: Alessia Bellisario <[email protected]>
@jerelmiller jerelmiller merged commit cf07b86 into 3.9-docs Jan 29, 2024
29 checks passed
@jerelmiller jerelmiller deleted the jerel/document-loadable-query branch January 29, 2024 20:07
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
3 participants