createCompareList mutation
The createCompareList
mutation creates a new comparison list with products specified in the input
attribute.
Luma uses a widget to display the product name, price, and other information. To present this information without a widget, set the product attributes to be comparable at Stores > Attributes > Product >
Syntax
1
2
3
4
5
6
7
mutation {
createCompareList(
input: CreateCompareListInput
) {
CompareList
}
}
Example usage
The following example shows how to create a comparison list containing two products.
Request:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
mutation {
createCompareList(
input: {
products: ["1", "2"]
}
) {
uid
item_count
attributes {
code
label
}
items {
uid
product {
sku
name
description {
html
}
}
}
}
}
Response:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
"data": {
"createCompareList": {
"uid": "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD",
"item_count": 2,
"attributes": [
{
"code": "sku",
"label": "SKU"
},
{
"code": "description",
"label": "Description"
},
{
"code": "short_description",
"label": "Short Description"
},
{
"code": "activity",
"label": "Activity"
}
],
"items": [
{
"uid": "1",
"product": {
"sku": "24-MB01",
"name": "Joust Duffle Bag",
"description": {
"html": "<p>The sporty Joust Duffle Bag can't be beat - not in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.<p>\n<ul>\n<li>Dual top handles.</li>\n<li>Adjustable shoulder strap.</li>\n<li>Full-length zipper.</li>\n<li>L 29\" x W 13\" x H 11\".</li>\n</ul>"
}
}
},
{
"uid": "2",
"product": {
"sku": "24-MB04",
"name": "Strive Shoulder Pack",
"description": {
"html": "<p>Convenience is next to nothing when your day is crammed with action. So whether you're heading to class, gym, or the unbeaten path, make sure you've got your Strive Shoulder Pack stuffed with all your essentials, and extras as well.</p>\n<ul>\n<li>Zippered main compartment.</li>\n<li>Front zippered pocket.</li>\n<li>Side mesh pocket.</li>\n<li>Cell phone pocket on strap.</li>\n<li>Adjustable shoulder strap and top carry handle.</li>\n</ul>"
}
}
}
]
}
}
}
Input attributes
The CreateCompareListInput
input object defines the product IDs for to be compared.
CreateCompareListInput attributes
The CreateCompareListInput
object contains the following attributes:
Attribute | Data Type | Description |
---|---|---|
products |
[ID!] | An array of product id values to add to the comparison list. Note that these are not uid values |
Output attributes
The CompareList
output object contains the following attributes:
Attribute | Data Type | Description |
---|---|---|
attributes |
[ComparableAttribute] | An array of attributes that can be used for comparing products |
item_count |
Int! | The number of items in the comparison lists |
items |
[ComparableItem] | An array of products to compare |
uid |
ID! | The unique ID of a CompareList object |
ComparableAttribute attributes
The ComparableAttribute
object lists the attributes that are available for comparisons:
Attribute | Data Type | Description |
---|---|---|
code |
String! | An attribute code that is enabled for product comparisons |
label |
String! | The label of the attribute code |
ComparableItem attributes
The ComparableItem
object lists items that have been added to the comparison list:
Attribute | Data Type | Description |
---|---|---|
attributes |
[ProductAttribute]! | An array of product attributes that can be used to compare products |
product |
ProductInterface! | Contains details about a product in a comparison list |
uid |
ID! | The unique ID of a ComparableItem object |
ProductAttribute object
The ProductAttribute
object outputs item data from the corresponding attribute:
Attribute | Data Type | Description |
---|---|---|
code |
String! | The unique identifier for a product attribute code |
label |
String! | The display value of the attribute |