Build the mental model
GraphQL separates reads with the `query` operation type from writes with `mutation`. Top-level query fields can execute in parallel, but top-level mutation fields execute serially, one after another, keeping side-effect order predictable. By convention, a mutation should return the object it just changed so the client sees the updated state immediately without a follow-up query.
Connect it to a real scenario
When an author publishes a tutorial on the Tutorial Platform, the frontend calls `publishTutorial(id: $id)` and immediately gets back the updated `status` and `publishedAt`, so it can apply an optimistic UI update right away.
Try the working example
mutation PublishTutorial($id: ID!) {
publishTutorial(id: $id) {
id
status
publishedAt
}
}
# variables: { "id": "42" }You can write a mutation operation and read back the state it changed.5-minute try-it
Design an `archiveTutorial(id: ID!)` mutation and write a selection set that returns the updated `status` field.
One important caution
Do not perform side effects inside a `query` operation's fields — the GraphQL spec assumes query fields are side-effect-free, idempotent reads.
GraphQL — Queries and Mutations — GraphQL