# Meal Plan generation

This document will help you diagnose and resolve common issues when generating a meal plan.

To check the meal plan settings, execute the [`debugMealPlanVariables`](https://docs.suggestic.com/graphql/query/queries/meal-plan/meal-plan-config) query.

## Issue 1: Couldn't generate a meal plan

This is a very common scenario in which the meal plan couldn't generate. Possible scenarios and solutions are described below:

### **Cause A:&#x20;*****Macro goals are high***

**Mutation:** `generateMealPlan`

**Error message:** *Couldn't generate a meal plan with the current settings.*

You will see the following error:

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2F2cux2LOqzIYftqvZe1ut%2Fimage.png?alt=media\&token=9beca1e7-f16c-46b3-9c12-a27cb6c51c0f)

**Solution:**

When you define the meal plan settings, the macros need to be set up according to the number of meals you have.

**Example:**

What happened if you define the following meal plan settings

```graphql
mutation updateMealPlanSettings {
  updateMealPlanSettings(
    update: {
      calories: 1500
      carbs: 45
      protein: 25
      fat: 30
      omega3: 9
      format: [BREAKFAST, SNACK, LUNCH, SNACK, LUNCH, DINNER, SNACK]
    }
  ) {
    success
    message
  }
}
```

You are asking for 250 kcal per meal approximately, and you have three snacks and four meals when you have a value of 1500 kcal. If you try to distribute that number of kcal in all the meals, no recipes will be found.

In this case, redistribute your macro values, specifically increase the calories value  and decrease the omega3 value as in the example below:

```graphql
mutation updateMealPlanSettings {
  updateMealPlanSettings(
    update: {
      calories: 2500
      carbs: 45
      protein: 25
      fat: 30
      omega3: 3
      format: [BREAKFAST, SNACK, LUNCH, SNACK, DINNER, SNACK]
    }
  ) {
    success
    message
  }
}
```

Finally, generate your meal plan again.

### **Cause B:** ***The meal plan generates just a few days***

**Mutation:** `generateMealPlan`

**Error message:** *none*

You will get a 1-day meal plan generated:

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2Fh4a0RtesQoJW14GI9lmk%2Fimage.png?alt=media\&token=7ca8ada3-9de2-477e-bd7f-e62855703178)

**Solution:**

When you define the meal plan settings, the macros need to be set up according to the number of meals you have.

**Example**

When you set up a meal plan, make sure to distribute the calories according to the number of meals defined. In the following example, 4000 kcal is distributed between two meals; therefore, there are not enough recipes to display.

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FLXHQPGWBGlytgzQefVoi%2Fimage.png?alt=media\&token=9880d2e9-3eba-41ba-96c3-eb5bc592e6f8)

Modify the setting to meet the caloric distribution according to the meals:

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

```graphql
mutation updateMealPlanSettings {
  updateMealPlanSettings(
    overwrite: {
      calories: 2000
      format: [BREAKFAST, LUNCH]
      
    }
  ) {
    success
    message
  }
}
```

{% endtab %}
{% endtabs %}

Generate a meal plan, and see that now it generated a 7-day meal plan:

```graphql
{
  "data": {
    "mealPlan": [
      {
        "day": 7,
        "date": "2022-06-05",
        "calories": 1972.42838098616,
        "meals": [
          {
            "id": "TWVhbDo4MTc1NzM1",
            "calories": 552.008164750333,
            "meal": "breakfast",
            "numOfServings": 1,
            "recipe": {
              "name": "Brunch Frittata",
              "numberOfServings": 3,
              "nutrientsPerServing": {
                "calories": 552.01
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzM2",
            "calories": 546.169072447844,
            "meal": "lunch",
            "numOfServings": 1,
            "recipe": {
              "name": "Keto Broccoli Cheddar Soup",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 546.17
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzM3",
            "calories": 874.251143787988,
            "meal": "dinner",
            "numOfServings": 4,
            "recipe": {
              "name": "Veggie Noodles And Chicken",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 218.56
              }
            }
          }
        ]
      },
      {
        "day": 6,
        "date": "2022-06-04",
        "calories": 1918.33252123767,
        "meals": [
          {
            "id": "TWVhbDo4MTc1NzMy",
            "calories": 642,
            "meal": "breakfast",
            "numOfServings": 3,
            "recipe": {
              "name": "Greek Frittata",
              "numberOfServings": 6,
              "nutrientsPerServing": {
                "calories": 214
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzMz",
            "calories": 547.788508237667,
            "meal": "lunch",
            "numOfServings": 1,
            "recipe": {
              "name": "Greek Salad With Grilled Salmon",
              "numberOfServings": 3,
              "nutrientsPerServing": {
                "calories": 547.79
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzM0",
            "calories": 728.544013,
            "meal": "dinner",
            "numOfServings": 2,
            "recipe": {
              "name": "Apple-And-Cheddar Frittata Recipes",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 364.27
              }
            }
          }
        ]
      },
      {
        "day": 5,
        "date": "2022-06-03",
        "calories": 2001.29971515398,
        "meals": [
          {
            "id": "TWVhbDo4MTc1NzI5",
            "calories": 698.7573,
            "meal": "breakfast",
            "numOfServings": 3,
            "recipe": {
              "name": "Supercharged Spinach Pancakes",
              "numberOfServings": 3,
              "nutrientsPerServing": {
                "calories": 232.92
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzMw",
            "calories": 579.788678818819,
            "meal": "lunch",
            "numOfServings": 1,
            "recipe": {
              "name": "Mexican-Style Stuffed Zucchini",
              "numberOfServings": 3,
              "nutrientsPerServing": {
                "calories": 579.79
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzMx",
            "calories": 722.753736335157,
            "meal": "dinner",
            "numOfServings": 1,
            "recipe": {
              "name": "Bbq Chicken With Sweet Chili–Peach Glaze",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 722.75
              }
            }
          }
        ]
      },
      {
        "day": 4,
        "date": "2022-06-02",
        "calories": 1910.97340571106,
        "meals": [
          {
            "id": "TWVhbDo4MTc1NzI2",
            "calories": 570.058513333333,
            "meal": "breakfast",
            "numOfServings": 1,
            "recipe": {
              "name": "Tumeric Omelette",
              "numberOfServings": 1,
              "nutrientsPerServing": {
                "calories": 570.06
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzI3",
            "calories": 599.706925827729,
            "meal": "lunch",
            "numOfServings": 1,
            "recipe": {
              "name": "Easy Keto Alfredo",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 599.71
              }
            }
          },
          {
            "id": "TWVhbDo4MTc1NzI4",
            "calories": 741.20796655,
            "meal": "dinner",
            "numOfServings": 2,
            "recipe": {
              "name": "Enchilada Chicken Recipes",
              "numberOfServings": 4,
              "nutrientsPerServing": {
                "calories": 370.6
              }
            }
          }
        ]
      },
      {
        "day": 3,
        "date": "2022-06-01",
        "calories": 1961.44286145526,
        "meals": [
.......
```

### **Cause C:** ***Macros don't match with the current program***&#x20;

**Mutation:** `generateMealPlan`

**Error message:** *Couldn't generate a meal plan with the current settings.*

One of the most challenging aspects of doing ***a vegan or keto*** diet is defining the recommended macros accordingly.&#x20;

**Solution:**

When you define the meal plan settings, macros or restrictions must be defined according to the program assigned.

**Example**

In the example below, the following information is setup:

Program: **Keto**

Macro Goals:

* Calories: 3000&#x20;
* Fat: 20&#x20;
* Carbs:15&#x20;
* Protein: 65

Meal Plan format:  `[BREAKFAST, LUNCH, DINNER]`&#x20;

When trying to generate a meal plan, the following message is displayed:

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2Fr0e5boTVRb5AfamZcoST%2Fimage.png?alt=media\&token=1703d481-bb04-49a4-971d-7984584a5d42)

This error appears because of the macros and restrictions defined in the keto program.&#x20;

Meal Plan settings must be modified according to the Keto Diet which includes the following recommendations:

* Calories: 900 kcal per day
* Fat: 70%
* Carbs: 5%
* Protein: 25%

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FYCgINe6wfDoIJ2pN3rSv%2Fimage.png?alt=media\&token=930fa3f0-6417-45b8-b8ae-c64c23771698)

After modifying the meal plan settings, generate it again.&#x20;
