# Macro Goals

Use the `macroGoals` query to obtain the total sum of macros logged for a particular date, the user's macronutrient goals (if goals are active), and the amount left.

## Requirements

* Execute the [`updateMealPlanSettings`](https://docs.suggestic.com/graphql/query/mutations/user-profile/update-meal-plan-settings) mutation to set the user's basic information, i.e: weight, height, age, etc.&#x20;

## Consideration

If the user updates their daily caloric intake by using the meal plan settings, [`profileMealPlanSettings`](https://docs.suggestic.com/graphql/query/mutations/user-profile/profile-meal-plan-settings),  the counted calories will be the ones the user or the application set by using that mutation.

### Required Argument

| Argument | Type  | Description                             |
| -------- | ----- | --------------------------------------- |
| `Date`   | Date! | Date to obtain the sum of macros logged |

### Available Fields

| Field                                                                      | Type              | Note                                                                                                                                       |
| -------------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `name`                                                                     | ID                | ID of the program. Use the [`programs` ](https://docs.suggestic.com/graphql/query/queries/program/programs)mutation to get the program ID. |
| `bmr`                                                                      | Int               | Basal Metabolic Rate                                                                                                                       |
| [`bmi`](https://docs.suggestic.com/graphql/helpful-resources/glossary#bmi) | Int               | Body Mass Index calculated from user's weight and height values.                                                                           |
| `tdee`                                                                     | Int               | Totaly Daily Energy Expenditure                                                                                                            |
| `cd`                                                                       | Int               | Caloric Deficit                                                                                                                            |
| `dcig`                                                                     | Int               | Daily Caloric Intake Goal                                                                                                                  |
| `isUserGoal`                                                               | Boolean           | **True** if this is the user's goal. Otherwise, it will be **False**                                                                       |
| `carbs`                                                                    | MacroNutrientGoal | An object that contains predefined macronutrient goals                                                                                     |
| `fat`                                                                      | MacroNutrientGoal | An object that contains predefined macronutrient goals                                                                                     |
| `protein`                                                                  | MacroNutrientGoal | An object that contains predefined macronutrient goals                                                                                     |
| `netcarbs`                                                                 | MacroNutrientGoal | An object that contains predefined macronutrient goals                                                                                     |

### MacroNutrientGoal

It includes the following objects:

* carbs
* fat
* protein
* netcarbs

Find the available fields for these objects:

#### Available fields

| Field name | Type   | Description                                                                                                                                                                                  |
| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `goal`     | String | Goal's user expressed in grams                                                                                                                                                               |
| `logged`   | Int    | The quantity of food the user has been intaken. This information is extracted while the user logs the food intake. This information is expressed in grams.                                   |
| `left`     | Int    | The amount left, expressed in grams, to reach the goal.                                                                                                                                      |
| `color`    | String | <p><strong>White:</strong> There are missing macros to reach the goal.</p><p><strong>Green:</strong> The goal has been reached.</p><p><strong>Red:</strong> The goal has been exceeded. </p> |

## Example

The following example retrieves the user macro goals information for a given date.

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

```graphql
{
  macroGoals(date: "2021-07-09") {
    name
    bmr
    bmi
    tdee
    cd
    dcig
    isUserGoal
    carbs {
      goal
      logged
      left
      color
      upperLimit
      lowerLimit
    }
    fat {
      goal
      logged
      left
      color
      upperLimit
      lowerLimit
    }
 
    netcarbs {
      goal
      logged
      left
      color
      upperLimit
      lowerLimit
    }
    protein {
      goal
      logged
      left
      color
      upperLimit
      lowerLimit
    }
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "macroGoals": {
      "name": "Today's Intake",
      "bmr": 1126,
      "bmi": 22,
      "tdee": 1576,
      "cd": 250,
      "dcig": 1326,
      "isUserGoal": false,
      "carbs": {
        "goal": 149,
        "logged": 83,
        "left": null,
        "color": "white",
        "upperLimit": 5,
        "lowerLimit": 5
      },
      "fat": {
        "goal": 90,
        "logged": 87,
        "left": null,
        "color": "white",
        "upperLimit": 5,
        "lowerLimit": 5
      },
      "netcarbs": {
        "goal": 60,
        "logged": 48,
        "left": null,
        "color": null,
        "upperLimit": null,
        "lowerLimit": null
      },
      "protein": {
        "goal": 99,
        "logged": 50,
        "left": null,
        "color": "white",
        "upperLimit": 5,
        "lowerLimit": 5
      }
    }
  }
}
```

{% endtab %}
{% endtabs %}

The macro goals are also displayed within the Suggestic's app:

![Sample dashboard from the Suggestic app using the macroGoals query](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LwqSnBDpAb6mFZYLsuB%2F-MeVVe0GEnvi93EYG2qF%2F-MeWQjD8c-3besuMIYnc%2Fimage.png?alt=media\&token=c6339224-ec66-41fe-b685-f0a12bdb5548)
