Meal Plan

Returns a 7-day meal plan based on the user's profile.

The MealPlan query will return the current and previous 7-day meal plans for the user, so it will return a maximum of 14 days. Each day of the meal plan will contain a certain number of meals according to the user's profile.

Each meal contains a recipe with all its expected properties along with the amount of recommended servings (numOfServings).

Meal Plan Settings

Macros, caloric ranges, meals per day, and other settings can be defined for each user using the profileMealPlanSettings mutation. If this object is null, the meal plan will be generated using the user's goals.

Meal Plan Generation

In order for a meal plan to exists it first needs to be created using the generateMealPlan mutation.

Available Fields

Field

Type

Note

day

Int

Number of days in the returned meal plan

date

String

Date assigned to the "day" of the meal plan

calories

Float

Total calories (in Kcal) for the day

protein

Float

Total protein (g) for the day

carbs

Float

Total carbs (g) for the day

fat

Float

Total fat (g) for the day

meals

A Recipe along with the total calories of the meal, name of the meal, and amount of recommended servings

Example

{
  mealPlan {
    day
    date(useDatetime: false)
    calories
    meals {
      id
      calories
      meal
      numOfServings
      recipe {
        name
        numberOfServings
        nutrientsPerServing {
          calories
        }
      }
    }
  }
}

Example with total Macros

query{
  mealPlan{
    date
    calories
    protein
    carbs
    fat
    day
    meals{
      recipe{
        name
      	id
        mealTags
        tags
      }
    }
  }
}

As follows find an example of how the numOfServings, servingWeigth, numberOfServings, and weightInGramms are used and calculated within this mutation:

About Dates

Associated to each day of the meal plan, the date value contains the date that corresponds to that particular day based on the last time a meal plan was generated. Read more about how dates are assigned here.

Returned results are sorted by date in descending order.

In older versions of the API, dates were returned as datetimes in UTC, and you had to make sure to adjust for your user's timezone and convert the datetime to date in order to avoid issues with date assignment. For compatibility, this is still the default. To receive an already converted date, you have to send the useDatetime: false argument in the date field.

Unless you're working with an older version of the API, always send the useDatetime: false argument in the date field.

Normal Flow

  1. A new user is created, it doesn't have a meal plan yet

  2. Use generateMealPlan for the first time. This returns success=true if the meal plan is generated successfully.

    1. Call mealPlan to obtain the first set of 7 days (or the first meal plan).

    2. The first day (day 1) will have the date of the day in which you called generateMealPlan

  3. If at any time during the 7 days while a meal plan is "running" you call generateMealPlan, nothing will happen, unless the user's settings have changed. Read more here.

  4. At any time, you should use mealPlan to obtain the currently running meal plan. This will return up to 14 days. These 14 days normally represent the current "running meal plan" and the previous week (if it exists).

    1. Please note that in the cases where the user's profile has changed and generateMealPlan was used again (before the end of the running meal plan), then when looking at the data returned by mealPlan you may be looking at more than 2 meal plans in the same set of 14 days.

  5. When you reach day 7 you have 2 options

    1. Generate a new set of 7 days using generateMealPlan with addDays: true (the new day 1 will come after the "current" day 7)

    2. Repeat the previous 7 days using generateMealPlan with repeat: "date" (same behavior but with the same meals as before)

  6. If day 7 of the last running meal plan has gone by and a new meal plan has not been requested, then you'll still be looking at the original 7 days when calling mealPlan. At this point, you'll need to call generateMealPlan to request a new set of 7 days, as in point #2.

    1. The options in point #6 will also be available

    2. IMPORTANT: A new meal plan will not be automatically generated when the previous one has ended

  7. Any time you call generateMealPlan make sure the success status is True. If the value returned is False then a new meal plan failed to generate and will be looking at "old" data if you call mealPlan at this point.

Other Considerations

  • A margin of error has been set for the resulting meal plan for both calories and macronutrients

  • No meal will repeat on the same day

  • This query takes into account the user's goals, program, and preferences

  • A number of quality-related filters have been set, by default, in order to ensure high-quality meal plans:

    • Excludes recipes with under 40 calories per serving

    • Excludes recipes for desserts, sauces, dips, bread, cocktails, and similar

    • Excludes snacks with over 5 ingredients

    • Excludes recipes with over 15 servings

    • Excludes recipes with more than 45-minute of cooking and preparation time

    • Excludes 0 calorie foods

    • Excludes packaged foods

  • If a meal plan cannot be generated because of the user's restrictions, a message will be displayed

Last updated