Definition

Creating data in GraphQL is done using mutations, which allow clients to modify server-side data.


Core Concept

Mutations define operations that change data (e.g., create, update, delete).

They are defined in the Mutation type in the schema.


Schema Example

type Mutation {
  createUser(name: String!): User
}

Basic Mutation

mutation {
  createUser(name: "Zeeshan") {
    id
    name
  }
}

Response

{
  "data": {
    "createUser": {
      "id": "1",
      "name": "Zeeshan"
    }
  }
}

Using Variables (Recommended)