# Meal Tracker

Meal Tracker is a simplified version of food logging that only works for meal plan meals.

Use the `mealTracker` query to get the list of all tracked meals for a given range of dates.&#x20;

To obtain the list of tracked meals, it is required to have meal entries created. Refer to [this documentation](https://docs.suggestic.com/graphql/query/mutations/meal-plan/create-a-meal-entry) to create a meal tracker entry.

{% hint style="warning" %}
**Note:** Currently tracking service only supports [JWT authentication](https://docs.suggestic.com/graphql/graphql/authentication#jwt-authentication)
{% endhint %}

### **Required Arguments**

| Field       | Type | Note                                                                           |
| ----------- | ---- | ------------------------------------------------------------------------------ |
| `startDate` | Date | The date when the meal entry will start counting. Use the format: `YYYY-MM-DD` |
| `endDate`   | Date | The date when the meal entry will end counting. Use the format: `YYYY-MM-DD`   |

### Available Fields

The following fields will be displayed in the response:

| Field    | Type   | Note                                                                                                                                                                                |
| -------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mealId` | String | Id of the meal                                                                                                                                                                      |
| `value`  | String | <p>Value of the meal. Possible values:</p><p><code>SKIPPED</code>, <code>ATE</code>, <code>OTHER\_FOLLOWING</code>, <code>OTHER\_NOT\_FOLLOWING</code>, and <code>DELETE</code></p> |
| `date`   | Date   | It contains the date that corresponds to that particular `day` based on the last time a meal plan was generated.                                                                    |

## Examples

### GraphQL Example

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

```graphql
{
 mealTracker(startDate: "2019-10-06" endDate: "2021-10-13") 
  {
    mealId
    value
    date
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "mealTracker": [
      {
        "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpVeU16RTA=",
        "value": "SKIPPED",
        "date": "2021-08-26"
      },
      {
        "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpVeU16RTM=",
        "value": "OTHER_FOLLOWING",
        "date": "2021-08-26"
      },
      {
        "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpRek5EazI=",
        "value": "ATE",
        "date": "2021-08-17"
      },
      {
        "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpRek5EazU=",
        "value": "SKIPPED",
        "date": "2021-08-17"
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

### curl Example

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

```java
curl -XPOST 'https://production.suggestic.com/graphql' \
  -H 'Authorization: Bearer <User-JWT>' \
  -H 'Content-Type: application/json' \
--data-raw '{"query": "query { mealTracker(startDate:\"2019-10-06\", endDate:\"2021-10-13\") { mealId value date }}"}'
```

{% endtab %}

{% tab title="Response" %}

```java
{
    "data": {
        "mealTracker": [
            {
                "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpVeU16RTA=",
                "value": "SKIPPED",
                "date": "2021-08-26"
            },
            {
                "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpVeU16RTM=",
                "value": "OTHER_FOLLOWING",
                "date": "2021-08-26"
            },
            {
                "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpRek5EazI=",
                "value": "ATE",
                "date": "2021-08-17"
            },
            {
                "mealId": "TWVhbFRyYWNrOlRXVmhiRG94TXpRek5EazU=",
                "value": "SKIPPED",
                "date": "2021-08-17"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}
