orval
orval copied to clipboard
Conflict between useMutation and useQuery configuration
There is a conflict when enabling both useMutation and useQuery for the same operation in the orval package configuration. This results in two functions with identical names being generated, which causes issues. Here is an example of the problematic configuration:
What happens?
{
operations: {
toolsValidateIban: {
query: {
useMutation: true,
useQuery: true
}
}
}
}
This generates two functions named useToolsValidateIban, one for useMutation and one for useQuery. While this is expected behavior, it leads to a naming conflict.
Proposed Solution
To resolve this, it would be beneficial to allow customization of the hook names within the operation configuration, especially for exceptions like this where both useMutation and useQuery are required. For example:
{
operations: {
toolsValidateIban: {
query: {
useMutation: {
enabled: true,
hookName: 'useToolsValidateIbanMutation'
},
useQuery: true
}
}
}
By allowing the hook name to be customized for useMutation, it would prevent the naming conflict and allow both functionalities to coexist.
Steps to Reproduce
- Configure an operation with both useMutation and useQuery set to true.
- Observe that two functions with the same name are generated.
Expected Behavior
There should be an option to customize the hook names to avoid conflicts, ensuring both useMutation and useQuery can be used simultaneously without issues.
What versions are you using?
Operating System: MacOS 15 Package Version: 6.31.0