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 a react-query default mutationKey that is the name of the mutation function (e.g. useCreateUser) #1249

Open
brockklein opened this issue Mar 5, 2024 · 0 comments
Labels
enhancement New feature or request tanstack-query TanStack Query related issue

Comments

@brockklein
Copy link

What are the steps to reproduce this issue?

Not exactly a reproducible issue other than the fact that generated react-query mutations do not have mutationKeys by default.

What happens?

When using a standard orval configuration for react-query no mutations have mutationKeys by default.

What were you expecting to hoping could happen?

Rather than having to manually add mutationKeys to every operation by hand, it would be awesome if orval could add a default mutationKey that is just the name of the mutator (e.g. useCreateUser).

This would allow someone (me 😁) to use a single mutationOptions override to handle case-by-case scenarios for different mutations based on the mutationKey.

Currently my custom mutationOptions override gets nicely inserted into each mutation, but there's no way for me to identify within the custom option implementation which mutation is happening. I can only provide generic mutation overrides (e.g. retryDelay).

With a mutationKey provided I could know which mutation is happening and then safely perform invalidations or local cache updates within onSuccess.

Any logs, error output, etc?

No logs or errors.

Any other comments?

n/a

What versions are you using?

Operating System: Ubuntu 22.04
Package Version: 6.25.0
Browser Version: n/a

@melloware melloware added the enhancement New feature or request label Mar 5, 2024
@melloware melloware added the tanstack-query TanStack Query related issue label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tanstack-query TanStack Query related issue
Projects
None yet
Development

No branches or pull requests

2 participants