Skip to content

Conversation

phryneas
Copy link
Member

No description provided.

@phryneas phryneas requested a review from a team as a code owner July 18, 2025 14:34
Copy link

changeset-bot bot commented Jul 18, 2025

⚠️ No Changeset found

Latest commit: d3e0b7c

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

pkg-pr-new bot commented Jul 18, 2025

npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@12781

commit: d3e0b7c

Copy link
Contributor

github-actions bot commented Jul 18, 2025

size-limit report 📦

Path Size
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (CJS) 42.82 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) (CJS) 37.93 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" 32.66 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) 27.06 KB (0%)
import { ApolloProvider } from "@apollo/client/react" 5.7 KB (0%)
import { ApolloProvider } from "@apollo/client/react" (production) 960 B (0%)
import { useQuery } from "@apollo/client/react" 7 KB (0%)
import { useQuery } from "@apollo/client/react" (production) 2.23 KB (0%)
import { useLazyQuery } from "@apollo/client/react" 6.88 KB (0%)
import { useLazyQuery } from "@apollo/client/react" (production) 2.13 KB (0%)
import { useMutation } from "@apollo/client/react" 6.22 KB (0%)
import { useMutation } from "@apollo/client/react" (production) 1.48 KB (0%)
import { useSubscription } from "@apollo/client/react" 6.57 KB (0%)
import { useSubscription } from "@apollo/client/react" (production) 1.79 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" 8.34 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" (production) 3.62 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" 8.13 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" (production) 3.38 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" 8.07 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" (production) 3.36 KB (0%)
import { useReadQuery } from "@apollo/client/react" 6.37 KB (0%)
import { useReadQuery } from "@apollo/client/react" (production) 1.63 KB (0%)
import { useFragment } from "@apollo/client/react" 6.45 KB (0%)
import { useFragment } from "@apollo/client/react" (production) 1.69 KB (0%)

@apollo-librarian
Copy link

apollo-librarian bot commented Jul 18, 2025

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 39a65431826bb6be8b2f223d

@phryneas
Copy link
Member Author

!docs set-base-branch main

@phryneas phryneas force-pushed the pr/hooks-docs branch 2 times, most recently from 1021a5e to 8aaea4b Compare July 21, 2025 08:28
@phryneas phryneas force-pushed the pr/docs-update/localState branch from 8e453f1 to f1e7ef0 Compare July 21, 2025 13:42
@apollo-librarian
Copy link

🛠️ Docs preview building...

The preview is currently being built.

Build ID: 87376bef33addd71f2ba7310

@jerelmiller jerelmiller force-pushed the pr/docs-update/localState branch from f1e7ef0 to 9cd56a9 Compare July 22, 2025 22:27
@jerelmiller jerelmiller changed the base branch from pr/hooks-docs to release-4.0 July 22, 2025 22:27
@jerelmiller jerelmiller force-pushed the pr/docs-update/localState branch from 9cd56a9 to 3e8cdda Compare July 22, 2025 22:30
@apollo-librarian
Copy link

🛠️ Docs preview building...

The preview is currently being built.

Build ID: 374bef2b3511200ef447c9b1

@apollo-librarian
Copy link

🛠️ Docs preview building...

The preview is currently being built.

Build ID: 40f0c63147af1965a675d6ac

Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

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

Had a few suggestions, but looks good overall.


After running the code generator, you can use the generated `Resolvers` type with your `LocalState` instance:

```ts
Copy link
Member

Choose a reason for hiding this comment

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

This code block could use another look for spacing.

### Code splitting
Depending on the complexity and size of your local resolvers, you might not always want to define them up front, when you create your initial `ApolloClient` instance. If you have local resolvers that are only needed in a specific part of your application, you can leverage Apollo Client's [`addResolvers` and `setResolvers`](#methods) functions to adjust your resolver map at any point. This can be really useful when leveraging techniques like route based code-splitting, using something like [`react-loadable`](https://github.com/jamiebuilds/react-loadable).
Depending on the complexity and size of your local resolvers, you might not always want to define them up front, when you create your initial `ApolloClient` instance. If you have local resolvers that are only needed in a specific part of your application, you can dynamically call `client.localState.addResolvers` to dynamically add new resolvers. This can be really useful when leveraging techniques like route based code-splitting.
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense to use client.localState.addResolvers or localState.addResolvers? In one example, localState is pulled out to a separate variable. I'm fine with either, but figured I'd pose the question.

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't show it as a separate variable everywhere, and especially when you create an empty local state and add resolvers dynamically, you might do it inline. So I went with the "safer" option here.

@phryneas phryneas force-pushed the pr/docs-update/localState branch from 3e8cdda to 0efa2ae Compare July 23, 2025 11:51
@phryneas phryneas merged commit 1fee553 into release-4.0 Jul 23, 2025
44 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants