WishlistMutation
Description
Wishlist operations are grouped in one source class and exposed as three GraphQL mutations:
addToWishlistremoveFromWishlistclearWishlist
All wishlist mutations require authenticated user context.
addToWishlist
Adds a product or entry to wishlist.
Endpoint
mutation addToWishlist($id: Int, $entryId: Int, $sku: String, $wishlistId: Int) {
addToWishlist(id: $id, entryId: $entryId, sku: $sku, wishlistId: $wishlistId) {
success
message
items {
id
entry_id
name
added_at
}
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| id | Int | No | Product element ID (used when wishlist identifier mode is id). |
| entryId | Int | No | Craft entry ID to resolve product from entry relation flow. |
| sku | String | No | Product SKU/handle (used when wishlist identifier mode is sku). |
| wishlistId | Int | No | Specific wishlist ID when multiple wishlists are supported. |
removeFromWishlist
Removes one wishlist item by item ID.
Endpoint
mutation removeFromWishlist($wishlistItemId: Int!) {
removeFromWishlist(wishlistItemId: $wishlistItemId) {
success
message
items {
id
entry_id
name
}
}
}
clearWishlist
Clears all wishlist items for the authenticated user.
Endpoint
mutation clearWishlist {
clearWishlist {
success
message
items {
id
entry_id
name
}
}
}
Return Values
All three operations return WishlistType:
| Field | Type | Description |
|---|---|---|
| success | Boolean | Mutation result state. |
| message | String | Result message. |
| items | [WishlistItemType] | Current wishlist snapshot after mutation. |
Notes
addToWishlistaccepts multiple identification strategies; plugin settinggqlWishlistProductIdentifierdecides whetheridorskuis required.- If
entryIdis provided, plugin resolves an entry first and adds related product to wishlist. - After every wishlist mutation, returned
itemscan be used to update UI without separate query call.