-
-
Notifications
You must be signed in to change notification settings - Fork 319
Closed
Labels
bug 🔥Broken or incorrect behavior.Broken or incorrect behavior.
Description
Description
I have implemented the following code:
const profileMutation = useMutation({
...updateUserMutation(),
onSuccess: () => {
toast({
title: "Success",
description: "Profile Updated"
});
},
onError: (error) => {
const errorMessage = getErrorMessage(error);
toast({
title: "Something went wrong",
description: errorMessage,
variant: "destructive",
});
},
onSettled: () => {
queryClient.invalidateQueries({ queryKey: ["readUser"] });
}
});I am encountering an issue determining the queryKey for readUser. The readUserOptions function is defined as follows:
export const readUserOptions = (options?: Options) => {
return queryOptions({
queryFn: async ({ queryKey }) => {
const { data } = await readUser({
...options,
...queryKey[0],
throwOnError: true,
});
return data;
},
queryKey: [createQueryKey("readUser", options)],
});
};The queryKey is generated by a function and it seems cumbersome to manually specify it for invalidateQueries. Could you advise on the best approach to handle this scenario?
Let me know if there's anything else you need!
Reproducible example or configuration
https://stackblitz.com/edit/hey-api-client-fetch-tanstackreact-query
OpenAPI specification (optional)
No response
System information (optional)
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug 🔥Broken or incorrect behavior.Broken or incorrect behavior.