query icon indicating copy to clipboard operation
query copied to clipboard

Add context as second parameter for the mutation function

Open asermax opened this issue 9 months ago • 2 comments

This PR adds a context that's passed as the second parameter to the mutationFn in a mutation. This change allows access to the mutation's meta (similar to query functions), which I find useful for passing in configurations (similarly as the case mentioned in https://github.com/TanStack/query/discussions/7045#discussioncomment-9151048). I've also included the mutationKey in the context, since it came up in a similar discussion #3504.

While this context could eventually include other information, I kept this initial contribution small and simple as to not get all tangled up with all the typing :sweat_smile:

asermax avatar Apr 28 '24 02:04 asermax

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
query ⬜️ Ignored (Inspect) Visit Preview Jun 22, 2024 4:07am

vercel[bot] avatar Apr 28 '24 02:04 vercel[bot]

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a750914dce87a143cd33dd205f17806807f7f4ca:

Sandbox Source
@tanstack/query-example-angular-basic Configuration
@tanstack/query-example-react-basic-typescript Configuration
@tanstack/query-example-solid-basic-typescript Configuration
@tanstack/query-example-svelte-basic Configuration
@tanstack/query-example-vue-basic Configuration

codesandbox-ci[bot] avatar Apr 28 '24 03:04 codesandbox-ci[bot]