Remove Meal Plan Recipe

Remove a recipe associated with a meal plan

Use the removeMealPlanRecipe mutation to remove a recipe that is associated with a meal plan. Remove either current or past recipes of any day. Note that the user does not remove the mealId; for instance, if the user has a Breakfast meal with an associated recipe, this is removed, and the numOfServings, calories, and maxNumOfServings fields values are 0; however, Breakfast meal as it is will still be listing.

Required Argument

Argument

Type

Description

mealId

ID!

Unique meal ID of the recipe associated with a meal plan. Use the mealPlan query to get this Id.

Available Fields

Field name

Type

Description

success

Boolean

True if the meal has been removed. Otherwise, it will display False

message

String

Description of the result

Examples

Remove a recipe by a given mealId

GraphQL Example

Get the mealId from the mealPlan query. From the following results the Breakfast mealId (WVhbDoxNTAzNDIx) from day 7 is chosen:

{
  "data": {
    "mealPlan": [
      {
        "day": 7,
        "date": "2021-10-12",
        "calories": 2465.42128283024,
        "meals": [
          {
            "id": "TWVhbDoxNTAzNDIx",
            "calories": 746.217929894105,
            "meal": "breakfast",
            "numOfServings": 1,
            "recipe": {
              "name": "Bircher Muesli",
              "numberOfServings": 1,
              "nutrientsPerServing": {
                "calories": 746.22
              }
            }
          },
          {
            "id": "TWVhbDoxNTAzNDIy",
            "calories": 1115.6275848875,
            "meal": "lunch",
            "numOfServings": 2,
            "recipe": {
              "name": "Pistachio Pesto Recipes",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 557.81
              }
            }
          }
            }
          }
        ]
      }
        ]
      }
    ]
  }
}

Replace that id in the mutation argument:


mutation removeMealPlanRecipe {
    removeMealPlanRecipe(mealId: "TWVhbDoxNTAzNDIx")
  {
    success
    message
  }
}

Once the meal is successfully removed, execute the meal plan query once more. The results will show a null value in the recipe. The rest of the field values related to the meal appear as 0.

{
  "data": {
    "mealPlan": [
      {
        "day": 7,
        "date": "2021-10-12",
        "calories": 2465.42128283024,
        "meals": [
          {
            "id": "TWVhbDoxNTAzNDIx",
            "calories": 0,
            "meal": "breakfast",
            "numOfServings": 0,
            "recipe": null
          },
          {
            "id": "TWVhbDoxNTAzNDIy",
            "calories": 1115.6275848875,
            "meal": "lunch",
            "numOfServings": 2,
            "recipe": {
              "name": "Pistachio Pesto Recipes",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 557.81
              }
            }
          }
            }
          }
        ]
      }
        ]
      }
    ]
  }
}

cURL Example

curl -XPOST 'https://production.suggestic.com/graphql' \
  -H 'Authorization: Bearer <User-JWT>' \
  -H 'Content-Type: application/json' \
  --data-raw { "query": "mutation removeMealPlanRecipe{removeMealPlanRecipe(mealId: \"TWVhbDoxNTAzNTgx\"){ success message } }"

Last updated