> For the complete documentation index, see [llms.txt](https://docs.suggestic.com/graphql/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.suggestic.com/graphql/query/queries/recipes/recipe-swap-options.md).

# Recipe Swap Options

Retrieves similar recipes for meal plan swaps

Use the `recipeSwapOptions` query to retrieve "similar" and "on plan" recipes given a *recipeId*.

This query is commonly used to provide alternatives for swapping recipes on a meal plan with similar macronutrients.

The `serving` argument can be used with the `numOfServings` field from a `mealPlan` response to find alternative recipes with a similar amount of macronutrients.&#x20;

Recipes in the response have also a `serving` field to know how many of the total numbers of servings have to be served to keep a similar amount of macros.

If you already have a meal from a `mealPlan` query, you can use the `serving` argument to find more recipes. The recipes in the response will also have a `serving` field to know how many of the total numbers of servings have to be served to keep a similar amount of macros.

## Available Arguments

| **Argument** | **Required** | **Type** | **Description**                                         |
| ------------ | ------------ | -------- | ------------------------------------------------------- |
| `recipeId`   | True         | ID       | Original recipe ID.                                     |
| `serving`    | False        | Int      | The number of recipe servings served. Default to **1**. |

## Available Fields

| **Field Name** |                                          **Type**                                          |                                                                           **Description**                                                                           |
| :------------: | :----------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|    `onPlan`    | [RecipeSwapOptions](https://docs.suggestic.com/graphql/objects/recipe/recipe-swap-options) |  Object that retrieves other meals in the existing meal plan for the same `mealTime`. If the `size` parameter is not defined, **6** **onPlan** recipes are returned |
|    `similar`   | [RecipeSwapOptions](https://docs.suggestic.com/graphql/objects/recipe/recipe-swap-options) | It retrieves all the recipes different than the original but **similar** in macros. If the `size` parameter is not defined, **3** **similar** recipes are returned. |

{% hint style="warning" %}
Please note that *recipeSwapOptions* won't work for a user that doesn't have an active meal plan.
{% endhint %}

### Example

The following example retrieves `similar` and `onPlan` recipes.

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

```graphql
{
  recipeSwapOptions(
    recipeId: "UmVjaXBlOjZkNGZkMjY1LWRmYWItNDJmMS1iMWIxLTJmMjk0ZTFlNGFmNw=="
    serving: 1
  ) {
    similar {
      id
      databaseId
      name
      mealTags
      serving
      numberOfServings
    }
    onPlan {
      id
      databaseId
      name
      mealTags
      serving
      numberOfServings
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```javascript
{
  "data": {
    "recipeSwapOptions": {
      "similar": [
        {
          "id": "UmVjaXBlOmZiYmJiNzgzLWU1MTgtNDhlZi1hM2JhLTdmYjEzNjFlYjM1ZA==",
          "databaseId": "fbbbb783-e518-48ef-a3ba-7fb1361eb35d",
          "name": "Oatmeal Walnut Energy Bites",
          "mealTags": [
            "Breakfast"
          ],
          "serving": 2,
          "numberOfServings": 13
        },
        {
          "id": "UmVjaXBlOjE4NzRkYzFkLWE5Y2EtNDVhOC05NjMyLThjODE2NDg0NmI3NQ==",
          "databaseId": "1874dc1d-a9ca-45a8-9632-8c8164846b75",
          "name": "Green Smoothie",
          "mealTags": [
            "Breakfast"
          ],
          "serving": 4,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmRiM2Q2OTgyLTM2NzEtNDlmOS05OGFiLWYxZjIxMGFjYTNmZA==",
          "databaseId": "db3d6982-3671-49f9-98ab-f1f210aca3fd",
          "name": "Energizing Green Matcha Smoothie Bowl",
          "mealTags": [
            "Breakfast"
          ],
          "serving": 4,
          "numberOfServings": 4
        }
      ],
      "onPlan": [
        {
          "id": "UmVjaXBlOmZhYmVjMGUzLTdkOTYtNGZhMC1hMWUwLWM4NjRhNDZkNDAyOA==",
          "databaseId": "fabec0e3-7d96-4fa0-a1e0-c864a46d4028",
          "name": "Cacao Chia Pudding",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmQzMDQ5N2I5LTA2OGQtNDdjYi05MTM3LWFhYmNlMjJkYjVhNA==",
          "databaseId": "d30497b9-068d-47cb-9137-aabce22db5a4",
          "name": "Carrot Cake Smoothie",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmE2Y2MwOWFjLTZlM2EtNDAyNi1hNjY4LWNkYzEzODI3ZWFmNA==",
          "databaseId": "a6cc09ac-6e3a-4026-a668-cdc13827eaf4",
          "name": "Eggs And Daikon Home Fries",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmI2Y2E1ZjY0LThkZWMtNDBkZS05MzBiLTQwNTZkNWU5OWNmZg==",
          "databaseId": "b6ca5f64-8dec-40de-930b-4056d5e99cff",
          "name": "Plant Protein Power Smoothie",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOjZjMDEyY2M3LWI1MjgtNDQ3Yy04Njc0LWE2MTUxZjI3ZjkxNA==",
          "databaseId": "6c012cc7-b528-447c-8674-a6151f27f914",
          "name": "Lentil Porridge With Mushrooms And Radish",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 3
        },
        {
          "id": "UmVjaXBlOmU2MDIyODAyLWIyM2UtNDkzMi04MmM4LWJkM2M3OGVlYTY3Yw==",
          "databaseId": "e6022802-b23e-4932-82c8-bd3c78eea67c",
          "name": "Green Smoothie",
          "mealTags": [
            "Breakfast"
          ],
          "serving": 1,
          "numberOfServings": 2
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}

The following example retrieves 2 similar recipes and 5 onPlan recipes

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

```graphql
{
  recipeSwapOptions(
    recipeId: "UmVjaXBlOjdmZTZkNWZkLTBhNmMtNGFhMC1hYmJhLWE2N2Y5NTg1NzEwZQ=="

  ) {
    similar (size:2) {
      id
      databaseId
      name
      mealTags
      serving
      numberOfServings
    }
    onPlan (size:5) {
      id
      databaseId
      name
      mealTags
      serving
      numberOfServings
      
    }
  }
}

```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "recipeSwapOptions": {
      "similar": [
        {
          "id": "UmVjaXBlOjliNjAwYTU2LTdjNmQtNGI0ZC05NTgzLTU2YjJlYTZmODBmMg==",
          "databaseId": "9b600a56-7c6d-4b4d-9583-56b2ea6f80f2",
          "name": "Sweet Orange Granola",
          "mealTags": [
            "Breakfast"
          ],
          "serving": 4,
          "numberOfServings": 2
        },
        {
          "id": "UmVjaXBlOmRiM2Q2OTgyLTM2NzEtNDlmOS05OGFiLWYxZjIxMGFjYTNmZA==",
          "databaseId": "db3d6982-3671-49f9-98ab-f1f210aca3fd",
          "name": "Energizing Green Matcha Smoothie Bowl",
          "mealTags": [
            "Breakfast"
          ],
          "serving": 4,
          "numberOfServings": 4
        }
      ],
      "onPlan": [
        {
          "id": "UmVjaXBlOmZhYmVjMGUzLTdkOTYtNGZhMC1hMWUwLWM4NjRhNDZkNDAyOA==",
          "databaseId": "fabec0e3-7d96-4fa0-a1e0-c864a46d4028",
          "name": "Cacao Chia Pudding",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmQzMDQ5N2I5LTA2OGQtNDdjYi05MTM3LWFhYmNlMjJkYjVhNA==",
          "databaseId": "d30497b9-068d-47cb-9137-aabce22db5a4",
          "name": "Carrot Cake Smoothie",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmE2Y2MwOWFjLTZlM2EtNDAyNi1hNjY4LWNkYzEzODI3ZWFmNA==",
          "databaseId": "a6cc09ac-6e3a-4026-a668-cdc13827eaf4",
          "name": "Eggs And Daikon Home Fries",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOmI2Y2E1ZjY0LThkZWMtNDBkZS05MzBiLTQwNTZkNWU5OWNmZg==",
          "databaseId": "b6ca5f64-8dec-40de-930b-4056d5e99cff",
          "name": "Plant Protein Power Smoothie",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 1
        },
        {
          "id": "UmVjaXBlOjZjMDEyY2M3LWI1MjgtNDQ3Yy04Njc0LWE2MTUxZjI3ZjkxNA==",
          "databaseId": "6c012cc7-b528-447c-8674-a6151f27f914",
          "name": "Lentil Porridge With Mushrooms And Radish",
          "mealTags": null,
          "serving": 1,
          "numberOfServings": 3
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.suggestic.com/graphql/query/queries/recipes/recipe-swap-options.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
