# Meal Plan Template Search

Use the `mealPlanTemplates` to find templates already created with the createMealPlanTemplate mutation.

{% hint style="info" %}
Use the `Authorization: Token <api-token>` to execute this query.&#x20;
{% endhint %}

### Available Arguments <a href="#available-fields" id="available-fields"></a>

| **Field Name** | **Type** |                                                              **Description**                                                              |
| -------------- | :------: | :---------------------------------------------------------------------------------------------------------------------------------------: |
| `search`       |  string  |                                         Introduce the word or the template name you want to find.                                         |
| `byCoach`      |    ID    |                           Unique Id of the Coach. Use this if the third party has access to the Coaching Portal                           |
| `excludeCoach` |    ID    | Unique Id of the Coach which information will be excluded from the search.  Use this if the third party has access to the Coaching Portal |
| `newerFirst`   |  boolean |                                    True if the results will show the newer meal plan templates created                                    |

### Available Fields

| **Field Name** | **Type** |                                     **Description**                                     |
| :------------: | :------: | :-------------------------------------------------------------------------------------: |
|      `id`      |    ID    |                                    Unique template ID                                   |
|  `description` |  String  |                               Description of the template                               |
|    `coachId`   |    ID    | Unique Coach Id template. Use this if the third party has access to the Coaching Portal |
|   `isPublic`   |  Boolean |          `T`**rue** if the template is Public. Otherwise it displays **False**          |
|    createdAt   | DateTime |                  Date and time when the meal plan template was created                  |

### Pagination

The `mealPlanTemplates` query supports the use of [pagination](https://docs.suggestic.com/graphql/start-here/tutorials-and-walkthroughs/pagination). The following fields can be used

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

```graphql
 pageInfo{
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
```

{% endtab %}
{% endtabs %}

### Example

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

```graphql
query {
  mealPlanTemplates {
    edges {
      node {
        id
        description
        createdAt
        coachId
        isPublic
        days {
          day
          meals {
            recipe {
              name
            }
            calories
            numOfServings
          }
        }
      }
    }
  }
}


```

{% endtab %}

{% tab title="Result" %}

```graphql
{
  "data": {
    "mealPlanTemplates": {
      "edges": [
        {
          "node": {
            "id": "TWVhbFBsYW5UZW1wbGF0ZTphY2FkYWY4Yy1jMWY5LTQyN2MtOGZlOS0zNjgyZjIxYThhYjE=",
            "description": "The very first",
            "createdAt": "2022-01-14T15:13:01.255979+00:00",
            "coachId": null,
            "isPublic": false,
            "days": [
              {
                "day": 1,
                "meals": [
                  {
                    "recipe": {
                      "name": "Caprese-Style Salad With Chicken"
                    },
                    "calories": 414.554124274375,
                    "numOfServings": 2
                  }
                ]
              }
            ]
          }
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}
