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
The two outcomes come back in different shapes, which is the one thing to get right when wiring a heart icon:
- Added — a normal success payload carrying the new
wishlistobject. - Removed — the wishlist object is
nulland the confirmation arrives inerrors[]as"Item Successfully Removed From Wishlist".
A removal therefore looks like a failure to a client that treats any errors[] entry as one. Read the message before deciding, or call Create Wishlist and Delete Wishlist separately when an unambiguous result matters more than a single round trip.
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" |

