# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.suggestic.com/graphql/start-here/tutorials-and-walkthroughs/executing-multiple-mutations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
