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 context as second parameter for the mutation function #7343

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

asermax
Copy link

@asermax asermax commented Apr 28, 2024

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 #7045 (comment)). 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 😅

Copy link

vercel bot commented Apr 28, 2024

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

@github-actions github-actions bot added documentation Improvements or additions to documentation package: query-core labels Apr 28, 2024
Copy link

codesandbox-ci bot commented Apr 28, 2024

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 a750914:

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

@asermax asermax force-pushed the feature/mutation-function-context branch from f60c661 to 8905437 Compare May 20, 2024 15:11
@asermax asermax force-pushed the feature/mutation-function-context branch from 8905437 to a750914 Compare June 22, 2024 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation package: query-core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant