Open
Description
openapi-react-query version
0.2.9
Description
MutationKey don't include params as can be seen in this code
useMutation(
{
mutationKey: [method, path],
mutationFn: async (init) => {
const mth = method.toUpperCase() as Uppercase<typeof method>;
const fn = client[mth] as ClientMethod<Paths, typeof method, Media>;
const { data, error } = await fn(path, init as InitWithUnknowns<typeof init>);
if (error) {
throw error;
}
return data as Exclude<typeof data, undefined>;
},
...options,
},
queryClient,
)
Use case
I wanna check if a mutation with a specific id is mutating or not.
Here id should be used for creating mutation key
Also there is a request to add createQueryKey function in your package
import { createQueryKey } from "@/client/utils";
import { useIsMutating } from "@tanstack/react-query";
export const usePayoutWalletState = (id: string) => {
const isMutating = useIsMutating({
mutationKey: createQueryKey("put", "/payout-wallets/{id}/set-default"),
});
return {
isMutating,
};
};
Reproduction
This issue is not related to any browser or specific conditions.
Expected result
I expected that mutationKey should include params same as used in queryOptions
const queryOptions: QueryOptionsFunction<Paths, Media> = (method, path, ...[init, options]) => ({
queryKey: [method, path, init as InitWithUnknowns<typeof init>] as const,
queryFn,
...options,
});
Extra
- I’m willing to open a PR (see CONTRIBUTING.md)