invalidateQuery

A type safe 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#

import { trpc } from '../utils/trpc'
// In component:
const utils = trpc.useContext();
const mutation = trpc.useMutation('editPost', {
onSuccess(input) {
utils.invalidateQuery(['allPosts']);
utils.invalidateQuery(['postById', input.id]);
},
})