Replies: 5 comments 4 replies
|
you mean fire off a But it's definitely possible: query/packages/query-core/src/tests/utils.ts Lines 35 to 44 in 5d29f8f |
|
@TkDodo How do you do it for V4? |
|
Hi, I've got quite the edge case where I also need to fire a mutation outside of react. export const updateProcess = async () => {
queryClient.getMutationCache().find({ mutationKey })?.execute();
};and export const updateProcess = async () => {
const mutation = queryClient.getMutationCache().find({ mutationKey });
if (mutation ) {
queryClient.getMutationCache().build(
queryClient, mutation.options, mutation.state.variables
).execute();
}
};but none of them works. In both cases the onMutate function throw an error saying that the expected params is undefined. Is there any way to do this or is it a stupid idea ? Btw I'm using react-query v4 |
|
I want to rebump this for query@v5. I too have the need to imperatively add data to the mutationCache (we have to react to a redux event in a saga (I know, I know)). For QueryCache, this is handled by I was a bit surprised to see the docs for Should I take these methods being undocumented to mean these are meant to be private? How "dangerous" is it to try and call these manually? query/packages/query-core/src/mutation.ts Line 176 in f6ae1cc |

you mean fire off a
mutation? There isn't much gain in doing that outside of react. You can't take advantage of the lifecycle management, so you can just as easily fire off a request with just fetch / axios.But it's definitely possible:
query/packages/query-core/src/tests/utils.ts
Lines 35 to 44 in 5d29f8f