How to generate a Meal Plan based on a template

The document will guide you through the steps to generate a meal plan based on a meal plan template

Overview

Different dietary plans do not require following a 7-day meal plan or having a fixed list of recipes generated randomly based on some parameters. Instead, people, including coaches, want to get more control over what they choose in a dietary plan.

Managing meal plan templates gives people the freedom to control what to choose to generate a meal plan, from the number of days to the recipes according to a user's needs.

Requirements

  • None

Considerations

  • Meal Plan Template endpoints only require sending the token within the header.

API Endpoints to use

Through the example, use the following endpoints in the same order as they are listed below:

  • Use any of the recipe search queries to find the recipes that best suit your dietary requirements

  • The createMealPlanTemplate to create a meal plan template according to your requirements.

  • The mealPlanTemplates to list the recent meal plan template created.

  • The generateMealPlan to generate the meal plan including the meal plan template ID.

  • The mealPlan to verify that the meal plan was generated based on the meal plan template.

Examples

The following example describes how to create a 3-day vegan meal plan based on the information added in a meal plan template. Find the characteristics of the meal plan to create as follows:

  • Number of days: 3

  • Meal Plan Template type: From Scratch

  • Meal Type: BREAKFAST, LUNCH, DINNER

  • Number of Servings: 2, 3, 2 respectively

Code Example

Find all the steps detailed below in this graphqlbin. Modify the code accordingly.

Step by Step Example

Follow the 5 steps below to generate a meal plan based on a meal plan template.

STEP 1: Get the List of recipes

In the case of the example, use the recipeSearch query to find vegan recipes:

Request:

Response:

From the response, copy the recipe id-> UmVjaXBlOmZjZDA0YTdmLWZjMTktNDljYi1iZDhjLTliNTFlM2ZmMDBjZA==. This will be later replace in the meal plan template creation.

Repeat the same action until you get all the recipes for the three days.

STEP 2: Create a meal plan template

The following example creates a 3-day meal plan. Copy and replace the IDs you got form the recipeSearch query into each one of the recipeId fields

STEP 3: Get the ID of the recently created meal plan template

Use the mealPlanTemplates to find the created meal plan template.

Request:

Response:

From the response, copy the recipe id-> TWVhbFBsYW5UZW1wbGF0ZTo3ODQyMDdkOC1lZjZmLTRlYmYtYTlmNC04YWVjNjQ3NjQ3MTA=. This will be later replace in the meal plan creation .

STEP 4: Generate the meal plan

Use the GenerateMealPlan to create the meal plan based on the template created before. In the request, use the fromTemplate argument to include the meal templated ID:

Note: You can include either the mealPlan object within the generateMealPlan mutation to retrieve the information of the meal plan created or use the mealPlan query separately to get this information.

Request:

Response:

STEP 5: Get the information of the meal plan

Execute the mealPlan query to retrieve the information of the recent meal plan created. Check that the 3 days have been created along with the information sent in the meal plan template.

Note that calories, the number of servings, calories per serving, and other nutritional information, are calculated automatically based on the recipe information.

Request:

Response:

Last updated

Was this helpful?