Create Compare Item
About
The createCompareItem mutation adds a product to the authenticated customer's comparison list. Use this mutation to:
- Add products to the compare list from product pages
- Implement "Add to Compare" buttons
- Build product comparison flows programmatically
- Allow customers to compare product features side by side
The customer is automatically detected from the Bearer token — no customer ID is needed in the input.
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 add to the comparison list. |
clientMutationId | String | Optional client-side mutation identifier for tracking. |
Possible Returns
| Field | Type | Description |
|---|---|---|
compareItem | CompareItem! | The newly created compare item. |
compareItem.id | ID! | IRI identifier (e.g. /api/shop/compare-items/607). |
compareItem._id | Int! | Numeric identifier. |
compareItem.product | Product! | The associated product. |
compareItem.customer | Customer! | The authenticated customer. |
compareItem.createdAt | String | Timestamp when the item was added. |
compareItem.updatedAt | String | Timestamp when the item was last updated. |

