Skip to content

feat(query-core): add MutationFunctionContext argument to mutateFn #9193

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

travikk
Copy link

@travikk travikk commented May 27, 2025

This PR adds new argument to mutateFn allowing for access to queryClient as well as meta object.

This feature should make it easier to attach authentication headers from within mutateFn, that would typically live in QueryCache. Currently that's made very difficult and requires either having singleton context in the codebase or requiring consumers of mutations to pass auth token each time.

This PR also makes it more similar to how queryFn behaves, in that it accepts QueryFunctionContext.

Note: I wasn't entirely sure about the name of MutateFunctionContext, but ultimately I decided to go ahead with that name to mirror the way queryFn behaves. I realise this might be suboptimal, due to there already existing a TContext for mutations. Happy to discuss and take direction here.

add new argument to mutateFn enabling access to queryClient as well as meta object
@github-actions github-actions bot added documentation Improvements or additions to documentation package: query-core labels May 27, 2025
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