What is a Mutation

A mutation in GraphQL is a write operation. While queries read data, mutations create, update, or delete it. Mutations are the GraphQL equivalent of POST, PUT, PATCH, and DELETE in REST.

How it works

A mutation looks like a query but starts with the mutation keyword:

mutation {
  createPost(title: "Hello", body: "World") {
    id
    title
    createdAt
  }
}

The server executes the mutation and returns the fields you requested from the result. Unlike queries, which can run in parallel, mutations execute sequentially in the order listed — ensuring predictable side effects.

Why it matters

Mutations make GraphQL a complete API — not just a read layer. By returning data from the mutation result, the client can update its local state without making a follow-up query. This eliminates the REST pattern of POST to create, then GET to read the created resource.

See How GraphQL Works for mutations, input types, and error handling.