Invalidate lists

Let say for example that you have a Todo type, a Query.todos query and a Mutation.addTodo mutation in your GraphQL API:

type Todo {
id: ID!
# ...
}
type Query {
todos: [Todo!]!
# ...
}
type Mutation {
addTodo(...): Todo
}

When the addTodo mutation passes through GraphCDN, it returns a new todo, for example:

{
"data": {
"addTodo": {
"id": "5"
}
}
}

Here, the automatic mutation invalidation cannot invalidate the Query.todos query automatically, as it doesn't know which list that todo was added to.

You have multiple ways to ensure the stale cached query results are invalidated correctly by manually purging from your backend:

  1. All queries that contain Todos (by calling purgeTodo without any arguments). Invalidates all queries that contain any toods, even if they might not have changed
  2. Giving your query a name (query getTodos { todos { ... } }) and purging any cached result of that query by its name (_purgeQuery(queries: [getTodos]))
  3. Determining one of the Todos that was previously in the list and purging that specifically (purgeTodo(id: latestTodoAlreadyInTheList.id))