Toggle Wishlist Item
About
The toggleWishlist mutation adds or removes a product from the authenticated customer's wishlist based on its current state. Use this mutation to:
- Implement toggle-style wishlist buttons (heart icons)
- Add a product if it's not in the wishlist
- Remove a product if it's already in the wishlist
- Simplify wishlist UI logic with a single mutation
Note: When a product is removed from the wishlist, the API returns an error-style response with the message
"Item Successfully Removed From Wishlist". When a product is added, a standard success response with the wishlist object is returned.
Authentication
This mutation requires customer authentication:
- Authenticated customers: Provide a valid customer authentication token in the
Authorizationheader. Obtain this token via the Customer Login API.
Authorization: Bearer <accessToken>Arguments
| Argument | Type | Description |
|---|---|---|
productId | Int | The ID of the product to toggle in the wishlist. |
clientMutationId | String | Optional client-side mutation identifier for tracking. |
Possible Returns
When item is added:
| Field | Type | Description |
|---|---|---|
wishlist | Wishlist! | The newly created wishlist item. |
wishlist.id | ID! | IRI identifier (e.g. /api/shop/wishlists/71). |
wishlist._id | Int! | Numeric identifier. |
wishlist.product | Product! | The associated product. |
wishlist.createdAt | String | Timestamp when the item was added. |
When item is removed:
| Field | Type | Description |
|---|---|---|
errors[].message | String! | "Item Successfully Removed From Wishlist" |

