Executing Multiple Mutations

This section will explain how to create multiple mutations.

Overview

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

It is not possible to execute nested mutations.

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.

Make sure each request has the response fields.

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

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

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

Last updated