User's Goals

Set user weight-related goals

Use the profileMacroGoalsSettings mutation to determine and set up a user's weight-related goals based on personal information such as weight, height, activity level, etc. Check this information to know which fields are used to calculate a user's caloric daily requirement.

The information is saved and read in the metric unit (kilograms, grams, meters, centimeters, etc). We DO NOT do unit conversions.

You are responsible for Unit Conversion. Make sure your units are correct.

Considerations to calculate your macros

Setup the goals

If goals are set as "on", those will be used. However, If they are not set or are "off" then for meal planning purposes, the meal plan will default to the program's pre-defined goal settings.

The following profile attributes relate to the goals' functionality and can be set directly on the user's profile.

If goals are on and the updateMealPlanSettings mutation is used, all the information will be overwritten.

Define your macro goals to lose weight

If the goal is to lose weight, your targetWeight have to be less than the currentWeight.

Check the following equation:

targetWeight<startingWeighttargetWeight < startingWeight

Then, define the rate to lose weight by choosing a weekly weight-related goal in the weeklyWeightGoalto add calories to the total daily expenditure.

Check this documentation to see the valid values to define for the weeklyWeightGoal

Example:

You will have the following macros:

  • currentWeight: 80kg

  • targetWeight: 60kg

  • weeklyWeightGoal: GOAL_1 (lose 0.5 kg)

This means that the user's goal is to lose 0.5 kg per week until the target weight is reached.

Define your macros goals to gain weight

If the goal is to gain weight, your targetWeight have to be greater than the currentWeight.

Check the following equation:

targetWeight>startingWeighttargetWeight > startingWeight

Then, define the rate to lose weight by choosing a weekly weight-related goal in the weeklyWeightGoalto add calories to the total daily expenditure.

Check this documentation to see the valid values to define for the weeklyWeightGoal

Example:

You will have the following macros:

  • currentWeight: 60kg

  • targetWeight: 80kg

  • weeklyWeightGoal: GOAL_1 (gain 0.5 kg)

This means that the user's goal is to gain 0.5 kg per week until the target weight is reached.

Available Arguments

Argument

is Required?

Type

Description

activityLevel

Yes

ActivityLevel

User's weekly activity level. Valid values are

- NOT_ACTIVE,

- EXERCISE_1 (1 - 2 times per week)

- EXERCISE_2 (3+ times per week) Use this to calculate your caloric daily requirement

biologicalSex

Yes

BiologicalSex

The biological sex of the user. Valid values are MALE and FEMALE Use this to calculate your caloric daily requirement

birthdate

Yes

Date

User's birthday. Use this to calculate your caloric daily requirement

goalsOn

Yes

Boolean

True if the goals functionality is enabled. Requires all other parameters to be set.

height

Yes

Float

The height of the user. Use this to calculate your caloric daily requirement . Expressed in centimeters

startingWeight

Yes

Float

The user's current weight. Use this to calculate your caloric daily requirement. Expressed in kilograms.

targetWeight

Yes

Float

The user's target weight. Use this to calculate your caloric daily requirement. Expressed in kilograms.

weeklyWeightGoal

Yes

WeeklyWeightGoal

User weekly weight-related goal. Depending on the user's goals, use this to gain, lose or maintain weight. Valid values are:

MANTAIN: maintain the weight,

GOAL_1: lose/gain 0.5 kg,

GOAL_2: lose/gain (1 kg),

GOAL_3: lose/gain (1.5 kg),

GOAL_4: lose/gain (4 kg) Use this to calculate your caloric daily requirement

Available Fields

The following field will be part of the response.

Field Name

Type

Description

success

Boolean

True if the user weight-related goals has been set successfully. Otherwise, False

The following fields are the result of the macro goals calculation:

Field Name

Type

Description

dcig

Int

Daily Caloric Intake Goal

Int

Caloric Difference between the daily caloric intake goal and the totaly daily energy expenditure

Int

Total Daily Energy Expenditure

Int

Basal Metabolic Rate calculated with the Harris–Benedict equation.

Int

Body Mass Index calculated from user's weight and height values.

Example

mutation {
  profileMacroGoalsSettings(
    goalsOn: true
    biologicalSex: FEMALE
    birthdate: "1982-01-10"
    height: 158 
    startingWeight: 70
    targetWeight: 58
    weeklyWeightGoal: GOAL_4
    activityLevel: EXERCISE_2
  ) {
    success
    bmr
    bmi 
    tdee 
    cd
    dcig 
  }
}

Execute the myProfile query to check these goals configured.

{
  myProfile {
    id
    age
    birthdate
    biologicalSex
    activityLevel
    startingWeight
    customAttributes
    targetWeight
    height
    weeklyWeightGoal
    goalsOn
    programName
    language
    subscription{
      id
      createdAt
      name
    }
    restrictions {
      name
    }
    dailyCaloricIntakeGoal
		caloricDifference 
		totalDailyEnergyExpenditure
		basalMetabolicRate
		program {
		  databaseId,
		  name
      author
		}
  }
}

PHP Example

<?php

$token = 'TOKEN';
$user = 'USER';

$query = <<<'GQL'
mutation profileMacroGoalsSettings(
    $biologicalSex: BiologicalSex!
    $birthdate: Date!
    $height: Float!
    $startingWeight:Float!
    $targetWeight: Float!
    $weeklyWeightGoal: WeeklyWeightGoal!
    $activityLevel: ActivityLevel!
  ){
    profileMacroGoalsSettings(
      biologicalSex: $biologicalSex,
      birthdate: $birthdate,
      goalsOn: true,
      height: $height,
      startingWeight: $startingWeight,
      targetWeight: $targetWeight,
      weeklyWeightGoal: $weeklyWeightGoal,
      activityLevel: $activityLevel
    ) {
      success
      bmr
      bmi 
      tdee 
      cd
      dcig 
    }
  }
  
GQL;

$variables = array(
    'biologicalSex' => 'FEMALE',
    'birthdate' => '1983-04-09',
    'height' => 179.71,
    'startingWeight' => 83,
    'targetWeight' => 73,
    'weeklyWeightGoal' => 'GOAL_3',
    'activityLevel' => 'NOT_ACTIVE',
);

$json = json_encode(['query' => $query, 'variables' => $variables]);

$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://production.suggestic.com/graphql',
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_POSTFIELDS => $json,
    CURLOPT_HTTPHEADER => array(
        'Authorization: Token ' . $token,
        'sg-user: ' . $user,
        'Content-Type: application/json',
    ) ,
));

$response = curl_exec($curl);
$result = curl_close($curl);
echo $result;

Last updated