zodios-react
zodios-react copied to clipboard
Automatically add `mutationKey` to mutations
First of all thanks for developing this awesome library, it has been a joy to work with it. I found a possible way to improve it but I'm not sure if you already considered the option.
Today I was trying to use TanStack Query's useIsMutating
like this:
const count = useIsMutating({
mutationKey: apiHooks.getKeyByAlias('updateCart', {
params: { id: cartId },
}),
});
but it was always returning 0, I had to do some digging to realize that I needed to explicitly pass the mutationKey
option to the useUpdateCart
hook:
apiHooks.useUpdateCart(
{ params: { id: cartId } },
{
mutationKey: apiHooks.getKeyByAlias('updateCart', {
params: { id: cartId },
})
}
)
So I think it will be good to add the mutationKey
automatically, let me know if it makes sense and I can create a PR for it.