Skip to main content
Version: 10.x

invalidateQueries

A typesafe wrapper around calling queryClient.invalidateQueries(), all it does is to call queryClient.invalidateQueries() with the passed args. See react-query docs if you want more fine-grained control.

Example code​

tsx
import { trpc } from '../utils/trpc';
// In component:
const utils = trpc.useContext();
const mutation = trpc.post.edit.useMutation({
onSuccess(input) {
utils.post.all.invalidate();
utils.post.byId.invalidate(input.id);
},
});
tsx
import { trpc } from '../utils/trpc';
// In component:
const utils = trpc.useContext();
const mutation = trpc.post.edit.useMutation({
onSuccess(input) {
utils.post.all.invalidate();
utils.post.byId.invalidate(input.id);
},
});