Skip to content

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

Arguments

ArgumentTypeDescription
productIdIntThe ID of the product to add to the comparison list.
clientMutationIdStringOptional client-side mutation identifier for tracking.

Possible Returns

FieldTypeDescription
compareItemCompareItem!The newly created compare item.
compareItem.idID!IRI identifier (e.g. /api/shop/compare-items/607).
compareItem._idInt!Numeric identifier.
compareItem.productProduct!The associated product.
compareItem.customerCustomer!The authenticated customer.
compareItem.createdAtStringTimestamp when the item was added.
compareItem.updatedAtStringTimestamp when the item was last updated.

Released under the MIT License.