# Food Log Guide

A log or logbook is a record of important information and it's comprised of a series of *entries* associated with a date and time. In the same way, a food log is a series of log entries that represent the consumption of different types of foods.

It is important to understand that **an entry in the food log doesn't represent the food itself but represents an "event" of food being consumed**. As such, it must include at least the following elements: date, time, food that was consumed, and the consumed quantity.

To add a new entry in the food log, for all cases, the [createMealLog mutation](/graphql/query/mutations/food-log/log-entries/meal-log-legacy/food-logs.md) should be used.

### Understanding meal types (mealType)

The first step to a successful implementation of food logging with the Suggestic API is understanding the different types of "loggable" objects defined under the concept of a [*`mealType`*](/graphql/objects/food-logs/meal-type.md)

| mealType     | Description                                          |
| ------------ | ---------------------------------------------------- |
| `RECIPE`     | A [recipe](/graphql/objects/recipe/recipe-object.md) |
| `USDA_MEAL`  | A meal or food from the USDA database                |
| `MENU_ITEM`  | A restaurant menu item                               |
| `OWN_RECIPE` | A recipe or meal created by the user                 |
| `OWN_ITEM`   | An individual food added/created by the user         |

Since each `mealType` is fundamentally different, the logging of each of these items will require a different set of parameters.

### Logging Recipes

To log a RECIPE you should use the [createMealLog mutation](https://docs.suggestic.com/graphql/query/mutations/food-log/food-logs), making sure you use the correct mealType. In this case, the `mealType`  would be RECIPE.&#x20;

Please note that you'll be using the `quantity` and `customServingEquivalent` fields and **not** the `serving` field.

**Example**

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

```graphql
mutation {
    createMealLog(
        mealType: RECIPE,
        mealTime: DINNER,
        mealDatabaseId: "a281aa17-e746-4780-b69b-b4c3597bb783",
        customServingEquivalent: 122.53701305389404,
        date: "2020-04-02",
        quantity: 1,
        time: "20:00"
    ) {
        success
        databaseId
    }
}
```

{% endtab %}

{% tab title="Result" %}

```graphql
{
  "data": {
    "createMealLog": {
      "success": true,
      "databaseId": "d2c233b6bca411eba1f9a6b553e671fd"
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Logging USDA Items

To log a USDA\_MEAL you should use the [createMealLog mutation](https://docs.suggestic.com/graphql/query/mutations/food-log/food-logs), making sure you use the correct mealType.&#x20;

Please note that you'll be using the `serving` field, **not** the `customServingEquivalent` field. &#x20;

### Logging Menu Items

To log a MENU\_ITEM you should use the [createMealLog mutation](https://docs.suggestic.com/graphql/query/mutations/food-log/food-logs), making sure you use the correct mealType.&#x20;

### Logging "Own Recipes"

To log an OWN\_RECIPE you should use the [createMealLog mutation](https://docs.suggestic.com/graphql/query/mutations/food-log/food-logs), making sure you use the correct mealType.&#x20;

### Logging "Own Items"

To log an OWN\_ITEM you should use the [createMealLog mutation](https://docs.suggestic.com/graphql/query/mutations/food-log/food-logs), making sure you use the correct mealType.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.suggestic.com/graphql/start-here/tutorials-and-walkthroughs/food-log-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
