# Executing Multiple Mutations

## Overview

Suggestic API supports the execution of multiple mutations in a single request.

{% hint style="warning" %}
It is not possible to execute nested mutations.
{% endhint %}

## How does it work?

If multiple mutations are part of the same request, they are executed **sequentially** in a single **transaction**. If any of the mutations fail, all the executed mutations will be rolled back.

## Examples

### Update the user program and profile restrictions

Even though the user program and profile restrictions can be set when creating a user, there aren't any mutations to update this information in a single request.

&#x20;Make sure each request has the response fields.

{% tabs %}
{% tab title="Mutation" %}

```graphql
mutation {
  updateUserProgram(
    programId: "UHJvZ3JhbTo2NDI1YTEwNS02MDQ4LTQ2OTktOWY1Yy02MzA3ZjZiM2RiYzk="
  ) {
    success
    message
  }
  profileRestrictionsUpdate(
    restrictions: [
      "UmVzdHJpY3Rpb246M2ZmZDQ1OGUtMjczZi00MTZmLWE5NjYtNmFkYzliYjQ3OWE1"
    ]
  ) {
    success
    message
  }
}

```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "updateUserProgram": {
      "success": true,
      "message": "User's program was successfully updated"
    },
    "profileRestrictionsUpdate": {
      "success": true,
      "message": "Profile updated"
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Update the meal plan settings and generate the meal plan

Create a single request to update the meal plan settings and then generate a meal plan

{% tabs %}
{% tab title="Mutation" %}

```graphql
mutation updateMealPlanSettings {
  updateMealPlanSettings(update: { calories: 1600, protein: 20 }) {
    success
    message
  }
  generateMealPlan {
    success
    message
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "updateMealPlanSettings": {
      "success": true,
      "message": "Settings updated"
    },
    "generateMealPlan": {
      "success": true,
      "message": "Meal plan generated."
    }
  }
}
```

{% endtab %}
{% endtabs %}
