orval icon indicating copy to clipboard operation
orval copied to clipboard

Add a react-query default mutationKey that is the name of the mutation function (e.g. useCreateUser)

Open brockklein opened this issue 11 months ago • 1 comments

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

brockklein avatar Mar 05 '24 03:03 brockklein

I'm missing this as well.

ruiaraujo012 avatar Oct 04 '24 15:10 ruiaraujo012