Learn what are mutations in GraphQL and how they can be used

About Mutations

In GraphQL, mutations are operations that modify data on the server. The mutation type in the schema defines GraphQL operations that create, update, or delete data.

For more information on mutations, refer to the "Forming Calls with GraphQL" section below.

Performing Mutations in GraphQL

Unlike queries, mutations are used to change data on the server. Similar to queries, mutations specify the data you want to operate on, but they also include the data you want to modify or create.

Mutations are structured like this:

mutation {

For an actual example, see "Example Mutation".

To interact with your GraphQL API and perform mutations, you need to follow a structured format. Here's how you can form mutation calls:

  1. Start with the mutation keyword: This indicates that you're performing a mutation operation.

  2. Provide the mutation name: Specify the name of the mutation you want to execute.

  3. Pass input data: If the mutation requires input, provide it as an input object within the mutation call.

  4. Define returned fields: Specify the fields you want to retrieve as part of the mutation response.

Last updated