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

  1. import { trpc } from '../utils/trpc'
  2. // In component:
  3. const utils = trpc.useContext();
  4. const mutation = trpc.useMutation('post.edit', {
  5. onSuccess(input) {
  6. utils.invalidateQueries(['post.all']);
  7. utils.invalidateQueries(['post.byId', input.id]);
  8. },
  9. })