6.1 Queries and Mutation inGraphQL
Mutations: Mutations are used to modify or create data on the GraphQL server. They are
analogous to `POST`, `PUT`, `PATCH`, or `DELETE` methods in RESTful APIs.
- Mutations define operations that modify the data, such as creating, updating, or
deleting objects.
- Mutations can have input parameters to pass data to the server.
- Example mutation:
mutation {
createUser(input: { name: "John Doe", email: "
[email protected]" }) {
id
name
email
}
}
This mutation creates a new user with the specified `name` and `email`, and then returns
the `id`, `name`, and `email` of the newly created user.