Technical Docs
Ask or search…
K

Generate Simple Meal Plan

Generate a simple meal
The generateSimpleMealPlan mutation generates a 7-days meal plan that complies with the user's program and preferences.

How the Simple Meal Plan works

The generateSimpleMealPlan includes default values, for example, each day has breakfast, lunch, dinner, and a single snack, with a daily caloric goal of 2000 kcal.

Use Filters

Use filters if what you need is to generate a meal plan with recipes that contain a specific caloric range or tags per mealtime.

Lock the meal plan

By default, generateSimpleMealPlan locks the meal plan to stop the user from generating a new meal plan if one is in progress. In other words, a user can't generate a new meal plan if the current one still has dates in the future.
If you need more control over these settings, please review the Generate Meal Plan mutation.

Manage Rules

The generateSimpleMealPlan inlcudes an option to increase or decrease rules depending on the rules defined in a program.

Allow repetitions in the meal plan

Generate a meal plan more consistently to simplify shopping by defining the variety argument to specify the number of repetitions per meal.
There are 3 levels of variety:
  • LOW: Generate three different meals in the week. For example, the meal plan generates three breakfasts, three lunches, three dinners, and three snacks distributed across the week.
  • MEDIUM: Generate 5 different meals in the week.
  • HIGH: All generated meals are different. This is the current behavior of the meal plan.
This is not a required argument, so if it is not defined, the high variety is set as default.

Considerations

Don't forget to execute the mealPlan query to verify that your meal plan has been created successfully.
To understand how a meal plan works refer to this guide.

Available Arguments

Argument Name
Type
Description
addDays
Boolean
True to allow generating a new meal plan if a user is on her last meal plan day. This field is ignored if ignoreLock is true. Default is false.
ignoreLock
Boolean
True to allow generating a new meal plan any time, overwriting any pending days in the current plan. Default is false.
repeat
Datetime
Create a new meal plan repeating the 7 dates after repeat in user's history. Default to null
boostAdherence
Boolean
True to consider increase and decrease rules in simpleMealPlan. All the recipes included will have a higher score. Otherwise is False. By default, this value is set to false
filters
Object that generate a simple meal plan by using specific information such as [cuisines] caloric range and tags
variety
MPVariety
Define the variety of the recipes generated in the meal plan. Possible Values: LOW, MEDIUM, or HIGH

Available Fields

The following fields will be displayed in the response:
Field
Type
Description
success
Boolean
True if a meal entry has been created. Otherwise, it displays False
message
String
Description of the result

Examples

Generate a 7-day meal plan

GraphQL Example

Mutation
Response
mutation {
generateSimpleMealPlan {
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}

cURL Example

Request
Response
curl -XPOST 'https://production.suggestic.com/graphql' \
-H 'Authorization: Bearer <User-JWT' \
-H 'Content-Type: application/json' \
--data-raw '{"query":"mutation GenerateSimpleMealPlan {generateSimpleMealPlan { success message }}"}'
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}
If the user doesn't have enough history days, the following message is displayed:
Mutation
Response
mutation {
generateSimpleMealPlan (addDays:true ignoreLock:false repeat:"2021-10-21T10:25:14.120000Z"){
success
message
}
{
"data": {
"generateSimpleMealPlan": {
"success": false,
"message": "Profile does not have enough days in history to complete a meal plan"
}
}
}

Generate a meal plan over a meal plan in progress

If you try using generateSimpleMealPlan, while a meal plan is in progress, you'll get the following response:
Request
Response
mutation {
generateSimpleMealPlan {
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": false,
"message": "User has a meal plan in progress."
}
}
}
To bypass the lock, send the argument ignoreLock: true .
Request
mutation {
generateSimpleMealPlan (addDays:true ignoreLock:true){
success
message
}
}

Generate a meal plan that increases and decreases the rules

GraphQL Example

Mutation
Response
mutation GenerateSimpleMealPlan {
generateSimpleMealPlan(boostAdherence: true) {
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}

cURL Example

Request
Response
curl -XPOST 'https://production.suggestic.com/graphql' \
-H 'Authorization: Bearer <User-JWT>' \
-H 'Content-Type: application/json' \
--data-raw '{"query":"mutation GenerateSimpleMealPlan{generateSimpleMealPlan(boostAdherence: true) {success message}}"}'
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}

Generate a meal plan by setting caloric range for each meal time

Request
Response
mutation {
generateSimpleMealPlan(
addDays: true
ignoreLock: true
filters: {
kcalRange: {
breakfast: { min: 100, max: 650 }
lunch: { min: 100, max: 400 }
snack: { min: 100, max: 300 }
dinner: { min: 100, max: 400 }
}
}
) {
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}

Generate a meal plan by setting caloric range and tags for each mealtime

Request
Response
mutation {
generateSimpleMealPlan(
addDays: true
ignoreLock: true
filters: {
kcalRange: { breakfast: { min: 100, max: 500 } }
tags: { snack: ["salad"] }
}
) {
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}

Generate a meal plan with a specific variety of recipes

Request
Response
mutation {
generateSimpleMealPlan (variety:MEDIUM){
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}

Generate a meal plan with a specific variety of cuisines

Request
Response
mutation {
generateSimpleMealPlan (filters:{cuisines:["Indian","Mexican","American"]}){
success
message
}
}
{
"data": {
"generateSimpleMealPlan": {
"success": true,
"message": "Meal plan was successfully created"
}
}
}