Skip to main content

Mutations

Mutations are the write side of your GraphQL API. They follow the same resolver pattern as queries but are conventionally used for operations that modify data.

Defining Mutations

Create a mutation type the same way you create a query type:
Mutation Type
Client mutation:

CRUD Example

Here’s a complete set of mutations for a Post resource:
Post CRUD Mutations

Input Validation

Validate inputs before persisting data:
Validation in Resolvers
Always validate inputs in mutations. GraphQL type checking only verifies that arguments are the right type — it doesn’t enforce business rules like “email must be unique” or “name must be at least 2 characters.”

Error Handling

Mutations that throw errors return structured error responses:
Error Responses
The client receives:

What’s Next

Playground

Test your mutations interactively with the built-in playground

Schema

Refine your schema with more types and relationships