# Add a Recipe to the Shopping List

Use `addToShoppingList` to add a recipe to the user's shopping list

#### Available Argument

| Arguments  | Type  | Description                              |
| ---------- | ----- | ---------------------------------------- |
| `recipeId` | UUID! | recipe database **UUID**                 |
| `servings` | Int   | Number of recipes to add for the recipe. |

### Available Fields

| **Field Name** | **Type** |                                          **Description**                                         |
| :------------: | :------: | :----------------------------------------------------------------------------------------------: |
|    `success`   |  Boolean | **True** if the recipe has been added to the shopping list. Otherwise, it will display **False** |
|    `message`   |  String  |                 Description of the result. Either if the recipe was added or not.                |

### Example

The following example adds the Fried Rice recipe to the shopping list.

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

```graphql
mutation {
  addToShoppingList(recipeId: "bd2f4b0c-83fc-4a45-8b2c-862bb31c85a9") {
    success
    message
  }
}
```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "addToShoppingList": {
      "success": true,
      "message": "Recipe successfully added"
    }
  }
}
```

{% endtab %}
{% endtabs %}

### Example with Servings

The following example adds one serving of the Fried Rice recipe to the shopping list.

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

```graphql
mutation {
  addToShoppingList(
    recipeId: "bd2f4b0c-83fc-4a45-8b2c-862bb31c85a9"
    servings: 1
  ) {
    success
    message
  }
}

```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "addToShoppingList": {
      "success": true,
      "message": "Recipe successfully added"
    }
  }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If a shopping list is created from a LOW variety meal plan, we suggest using the following logic.

* If a recipe is present only once in the meal plan —> add the recipe to the shopping list using the default number of servings of the recipe.
* If a recipe is present more than one time in the meal plan:
  * if recipe's default number of servings (i.e. 2) < number of times the recipe appears (ie. 3) —> add recipe to shopping list with the number of servings equal to how many times it shows up on the meal plan (ie. 3).
  * if recipe's default number of servings (i.e. 4) >= number of times the recipe appears (i.e. 2) —> add recipe with default number of servings.
    {% endhint %}

### UI/UX example

This is an implementation example from the Suggestic App.&#x20;

![](https://920729701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LwqSnBDpAb6mFZYLsuB%2Fuploads%2FhbzMSc4AQrh6BuKY5Qwu%2FListAddedShop1.gif?alt=media\&token=41ac8176-1433-4b43-a445-3e9d3ed67531)

## Add Multiple Recipes to a Shopping list

#### Available Argument

| Arguments   | Type         | Description                  |
| ----------- | ------------ | ---------------------------- |
| `recipeIds` | **`[UUID]`** | List of recipe database UUID |

### Example

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

```graphql
mutation {
  addRecipesToShoppingList(recipeIds: [
    "26400c11-125d-4782-b83c-6c74923ae9ab",
    "4719210c-fff5-4709-b6d2-7b460102843d"
  ]) {
    message
    success
  }
}

```

{% endtab %}

{% tab title="Response" %}

```graphql
{
  "data": {
    "addRecipesToShoppingList": {
      "message": "Recipes successfully added",
      "success": true
    }
  }
```

{% endtab %}
{% endtabs %}
