Skip to content

Add context as callback to useMutation mutate function#12959

Merged
jerelmiller merged 18 commits intorelease-4.1from
jerel/context-callback
Oct 10, 2025
Merged

Add context as callback to useMutation mutate function#12959
jerelmiller merged 18 commits intorelease-4.1from
jerel/context-callback

Conversation

@jerelmiller
Copy link
Copy Markdown
Member

Closes #12952

Adds the ability to provide a callback function to the context option provided to the mutate function returned from useMutation. This makes it possible to merge context from the hook if a value is only available when calling execute.

@jerelmiller jerelmiller requested a review from phryneas October 9, 2025 20:40
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Oct 9, 2025

🦋 Changeset detected

Latest commit: 9953e2c

The changes in this PR will be included in the next version bump.

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

@apollo-librarian
Copy link
Copy Markdown

apollo-librarian bot commented Oct 9, 2025

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 4 changed, 0 removed
* (developer-tools)/react/(latest)/data/mutations.mdx
* (developer-tools)/react/(latest)/data/queries.mdx
* (developer-tools)/react/(latest)/migrating/apollo-client-4-migration.mdx
* (developer-tools)/react/(latest)/performance/server-side-rendering.mdx

Build ID: 217f82b041d7f72625b3b17a
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/217f82b041d7f72625b3b17a

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Oct 9, 2025

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

commit: 398a19a

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 9, 2025

size-limit report 📦

Path Size
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (CJS) 43.7 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) (CJS) 38.57 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" 33.1 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) 27.1 KB (0%)
import { ApolloProvider } from "@apollo/client/react" 6.13 KB (0%)
import { ApolloProvider } from "@apollo/client/react" (production) 1001 B (0%)
import { useQuery } from "@apollo/client/react" 7.57 KB (0%)
import { useQuery } from "@apollo/client/react" (production) 2.39 KB (0%)
import { useLazyQuery } from "@apollo/client/react" 7.31 KB (0%)
import { useLazyQuery } from "@apollo/client/react" (production) 2.16 KB (0%)
import { useMutation } from "@apollo/client/react" 6.7 KB (+0.44% 🔺)
import { useMutation } from "@apollo/client/react" (production) 1.54 KB (+1.48% 🔺)
import { useSubscription } from "@apollo/client/react" 6.99 KB (0%)
import { useSubscription } from "@apollo/client/react" (production) 1.82 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" 8.78 KB (0%)
import { useSuspenseQuery } from "@apollo/client/react" (production) 3.67 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" 8.55 KB (0%)
import { useBackgroundQuery } from "@apollo/client/react" (production) 3.44 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" 8.52 KB (0%)
import { useLoadableQuery } from "@apollo/client/react" (production) 3.43 KB (0%)
import { useReadQuery } from "@apollo/client/react" 6.8 KB (0%)
import { useReadQuery } from "@apollo/client/react" (production) 1.66 KB (0%)
import { useFragment } from "@apollo/client/react" 6.86 KB (0%)
import { useFragment } from "@apollo/client/react" (production) 1.71 KB (0%)

@jerelmiller jerelmiller requested a review from a team as a code owner October 9, 2025 20:56
Copy link
Copy Markdown
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@github-actions github-actions bot added the auto-cleanup 🤖 label Oct 10, 2025
@jerelmiller jerelmiller merged commit 556e837 into release-4.1 Oct 10, 2025
31 of 33 checks passed
@jerelmiller jerelmiller deleted the jerel/context-callback branch October 10, 2025 15:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 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