TanStackT
TanStack3y ago
3 replies
verbal-lime

Is there a way to update a query cache after a mutation?

Like the name suggested, is there any way to update a query cache from a different component after a mutation? There is a way to do it with apollo client with GraphQL, but I'm using a REST api so is there something similar to this?

// Documentation from Apollo

const [addTodo, { data, loading, error }] = useMutation(ADD_TODO, {
  refetchQueries: [
    {query: GET_POST}, // DocumentNode object parsed with gql
    'GetComments' // Query name
  ],
});
Was this page helpful?