Creating data in GraphQL is done using mutations, which allow clients to modify server-side data.
Mutations define operations that change data (e.g., create, update, delete).
They are defined in the Mutation type in the schema.
type Mutation {
createUser(name: String!): User
}
createUser → mutation fieldname → input argumentUser objectmutation {
createUser(name: "Zeeshan") {
id
name
}
}
{
"data": {
"createUser": {
"id": "1",
"name": "Zeeshan"
}
}
}