Skip to content

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 Authorization header. Obtain this token via the Customer Login API.
Authorization: Bearer <accessToken>

Arguments

ArgumentTypeDescription
productIdIntThe ID of the product to toggle in the wishlist.
clientMutationIdStringOptional client-side mutation identifier for tracking.

Possible Returns

When item is added:

FieldTypeDescription
wishlistWishlist!The newly created wishlist item.
wishlist.idID!IRI identifier (e.g. /api/shop/wishlists/71).
wishlist._idInt!Numeric identifier.
wishlist.productProduct!The associated product.
wishlist.createdAtStringTimestamp when the item was added.

When item is removed:

FieldTypeDescription
errors[].messageString!"Item Successfully Removed From Wishlist"

Released under the MIT License.