-
Notifications
You must be signed in to change notification settings - Fork 32
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
New createMutationKeys doesn't work for mutations with arguments #55
Comments
I'm having this issue as well. I'm using this with graphql like so: export const checkoutMutations = createMutationKeys("checkout", {
create: {
mutationKey: ["create"],
mutationFn: (items: string[]) => {
return request(CREATE_CHECKOUT, {input: {items}})
}
}
}) When I try to use this like this: const createCheckout = useMutation(checkoutMutations.create) That works fine but when I call it later, I get an error: const result = await createCheckout.mutateAsync(cart.items.map(item => item.url))
=> TS2345: Argument of type 'string[]' is not assignable to parameter of type 'void'. |
It looks like it has to do with the default type arguments in |
@jetaggart and @brmenchl thanks for bringing more context to the issue! I'll take a look on how to fix this |
I am not sure if this is the problem (or at least a problem), but I noticed that |
Any updates on this problem? |
Not sure about react (using svelte) but you can just pass the types with the const institutionConnectionMutation = createMutationKeys('InstitutionConnectionMutation', {
create: () => ({
mutationKey: ['create'],
mutationFn: (request: InstitutionConnectionCreateRequest) => service.create(request),
}),
})
const mutation = createMutation<
InstitutionConnection,
Error,
InstitutionConnectionCreateRequest,
unknown
>({
...institutionConnectionMutation.create()
}); |
I first tried to follow the standard practice like for parametrized queries
I also tried
Neither gives me a workable type where I can pass in an argument. I could try to work on it myself but I'm not super familiar with this library yet.
The text was updated successfully, but these errors were encountered: