GraphQL Mutation
A GraphQL mutation uses the mutation { field(args) { result } } syntax to perform write operations and return results; it is the write entry point of GraphQL.
Purpose
To perform data changes (create/update/delete) in GraphQL and return the changed data, sharing the type system with queries.
Mechanism
The mutation keyword is followed by an operation name, variables, and a selection set. The server executes the mutation resolvers (side effects) and returns the fields declared in the selection set. It is separated from query so that serial execution is possible.
Use cases
- API data writes
- Form submission
- State changes