Automatic mutation invalidation

Mutations invalidate any cached query results that contain the object(s) you return fully automatically.

For example, imagine this GraphQL schema:

type Post {
id: ID!
author: User!
comments: [Comment!]!
}
type Mutation {
updatePost: Post!
}
mutation {
updatePost {
id
comments {
id
}
author {
id
}
}
}

Once the mutation completes, any query result that contains the Post with the returned ID and any query result that contains the User with the returned ID (at Post.authorand any query result that contains any of the comments with the returned IDs (at Post.comments[n].id) will fully automatically be invalidated.

Edge cases

The most common case where automatic mutation invalidation does not automatically invalidate data is when items are added to a list. You can learn more about how to manually purge in that case in How-to invalidate lists!