> 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 %}
