#6715·trpc

feat: add mutation args to useMutation onSucess override

Author: DawidWragaCreated Apr 21, 2025Updated Jul 8, 2026

Describe the feature you'd like to request

currently useMutationSucess override does not have access to the original args from the onSucess callback

see https://github.dev/trpc/trpc/blob/main/packages/tanstack-react-query/src/internals/mutationOptions.ts

This prevents setting up automatic query invalidation eg using these methods: https://tkdodo.eu/blog/automatic-query-invalidation-after-mutations

For example, if we had access to the mutationKey, then task.create mutation we can invalidate the task router, without invalidating the user router.

Describe the solution you'd like to see

Very simply just pass the original args to the mutationSuccessOverride here https://github.dev/trpc/trpc/blob/main/packages/tanstack-react-query/src/internals/mutationOptions.ts

or even just passing the mutationKey would be enough for my use case.

Describe alternate solutions

manually passing the mutation keys to the mutation meta

Additional information

No response

‍‍ Contributing

  • ‍♂️ Yes, I'd be down to file a PR implementing this feature!