Skip to main content

Add or remove a product from a favorite list

Add products to or remove products from a favorite (wish) list.

Add products

mutation AddToFavoriteList($listId: String!, $input: FavoriteListsItemsInput!) {
favoriteListAddItems(
id: $listId
input: $input
) {
id
name
products(input: { offset: 5 }) {
itemsFound
}
}
}

Variables

{
"listId": "66d6ab6e590599fecc3fa5a2",
"input": {
"productIds": [41, 44]
}
}

Response

{
"data": {
"favoriteListAddItems": {
"id": "66d6ab6e590599fecc3fa5a2",
"name": "IT supplies afdeling management",
"products": {
"itemsFound": 5
}
}
}
}

Remove products

mutation RemoveFromFavoriteList($listId: String!, $input: FavoriteListsItemsInput!) {
favoriteListRemoveItems(
id: $listId
input: $input
) {
id
name
products(input: { offset: 5 }) {
itemsFound
}
}
}

Variables

{
"listId": "66d6ab6e590599fecc3fa5a2",
"input": {
"productIds": [44]
}
}

Response

{
"data": {
"favoriteListRemoveItems": {
"id": "66d6ab6e590599fecc3fa5a2",
"name": "IT supplies afdeling management",
"products": {
"itemsFound": 4
}
}
}
}

How it works

Both mutations take the same FavoriteListsItemsInput which accepts productIds and/or clusterIds arrays. You can add or remove multiple products in a single call. The response returns the updated favorite list so you can refresh the product count in the UI. The list id is a 12 or 24 character string identifier. To add a cluster (product group) instead of individual products, use clusterIds in the input.

See also