Skip to main content

Mutations

GraphQL mutations are operations that allow the client to create, update, or delete data on the server. Unlike queries, which are read-only operations and can be executed in parallel, mutations are write operations.

For the inputs, you would append the action (Create, Update, or Delete) to the resource type. Here are examples of mutations for the Patient resource:

Create Mutation

  mutation {
PatientCreate(
res: {
resourceType: "Patient"
gender: "male"
name: [
{
given: "Homer"
}
]
}
) {
id
gender
name {
given
}
}
}
Example Response
  {
id: 'example-id',
name: {
given: 'Homer',
},
gender: 'male',
};

Put Mutation

mutation {
PatientUpdate(
id: "example-id"
res: {
id: "example-id"
resourceType: "Patient"
gender: "male"
name: [
{
given: "Bob"
},
{
family: "Smith"
}
]
}
) {
id
gender
name {
given
}
}
}
Example Response
  {
id: 'example-id',
name: {
given: 'Homer',
},
gender: 'male',
};

Delete Mutation

mutation {
PatientDelete(
id: "example-id"
) {
id
}
}