Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 4fbdb42

Browse files
authored
Merge pull request #8644 from andrewbess/new-topic/graphql/issue-7374-add-support-for-compare-lists
ISSUE-7374: The topics for the "Compare List" mutations have been created
2 parents 5912548 + cb0d42f commit 4fbdb42

File tree

10 files changed

+831
-1
lines changed

10 files changed

+831
-1
lines changed

src/_data/toc/graphql.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ pages:
8282
url: /graphql/queries/company.html
8383
edition: b2b-only
8484
exclude_versions: ["2.3"]
85-
85+
86+
- label: compareList query
87+
url: /graphql/queries/compare-list.html
88+
exclude_versions: ["2.3"]
89+
8690
- label: countries query
8791
url: /graphql/queries/directory-countries.html
8892

@@ -181,6 +185,10 @@ pages:
181185
- label: addDownloadableProductsToCart mutation
182186
url: /graphql/mutations/add-downloadable-products.html
183187

188+
- label: addProductsToCompareList mutation
189+
url: /graphql/mutations/add-products-to-compare-list.html
190+
exclude_versions: ["2.3"]
191+
184192
- label: addProductsToRequisitionList mutation
185193
url: /graphql/mutations/add-products-to-requisition-list.html
186194
edition: b2b-only
@@ -227,6 +235,10 @@ pages:
227235
url: /graphql/mutations/apply-store-credit.html
228236
edition: ee-only
229237

238+
- label: assignCompareListToCustomer mutation
239+
url: /graphql/mutations/assign-compare-list-to-customer.html
240+
exclude_versions: ["2.3"]
241+
230242
- label: changeCustomerPassword mutation
231243
url: /graphql/mutations/change-customer-password.html
232244

@@ -268,6 +280,10 @@ pages:
268280
edition: b2b-only
269281
exclude_versions: ["2.3"]
270282

283+
- label: createCompareList mutation
284+
url: /graphql/mutations/create-compare-list.html
285+
exclude_versions: [ "2.3" ]
286+
271287
- label: createCustomer mutation
272288
url: /graphql/mutations/create-customer.html
273289

@@ -320,6 +336,10 @@ pages:
320336
edition: b2b-only
321337
exclude_versions: ["2.3"]
322338

339+
- label: deleteCompareList mutation
340+
url: /graphql/mutations/delete-compare-list.html
341+
exclude_versions: [ "2.3" ]
342+
323343
- label: deleteCustomerAddress mutation
324344
url: /graphql/mutations/delete-customer-address.html
325345

@@ -371,6 +391,10 @@ pages:
371391
url: /graphql/mutations/redeem-giftcard-balance.html
372392
edition: ee-only
373393

394+
- label: removeProductsFromCompareList mutation
395+
url: /graphql/mutations/remove-products-from-compare-list.html
396+
exclude_versions: ["2.3"]
397+
374398
- label: removeCouponFromCart mutation
375399
url: /graphql/mutations/remove-coupon.html
376400

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Attribute | Data Type | Description
2+
--- | --- | ---
3+
`attributes` | [[ComparableAttribute]](#comparableAttributeObjectOutput) | An array of attributes that can be used for comparing products
4+
`item_count` | Int! | The number of items in the compare lists
5+
`items` | [[ComparableItem]](#comparableItemObjectOutput) | An array of products to compare
6+
`uid` | ID! | The unique ID of a `CompareList` object
7+
8+
### ComparableAttribute object {#comparableAttributeObjectOutput}
9+
10+
The `ComparableAttribute` object outputs attributes which available to comparison:
11+
12+
Attribute | Data Type | Description
13+
--- | --- | ---
14+
`code` | String! | An attribute code that is enabled for product comparisons
15+
`label` | String! | The label of the attribute code.
16+
17+
### ComparableItem object {#comparableItemObjectOutput}
18+
19+
The `ComparableItem` object outputs items that have been added to compare list:
20+
21+
Attribute | Data Type | Description
22+
--- | --- | ---
23+
`attributes` | [[ProductAttribute]!](#productAttributeObjectOutput) | An array of product attributes that can be used to compare products
24+
`product` | [ProductInterface!]({{ page.baseurl }}/graphql/interfaces/product-interface.html) | Contains details about a product in a compare list
25+
`uid` | ID! | The unique ID of a `ComparableItem` object
26+
27+
### ProductAttribute object {#productAttributeObjectOutput}
28+
29+
The `ProductAttribute` object outputs item data from the corresponding attribute:
30+
31+
Attribute | Data Type | Description
32+
--- | --- | ---
33+
`code` | String! | The unique identifier for a product attribute code
34+
`label` | String! | The display value of the attribute

src/_includes/graphql/customer-output-24.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{% if page.url contains 'graphql/queries/customer.html' %}
2+
{% assign comparelist_text = " '[CompareList](#CompareList)' %}
23
{% assign customeraddress_text = '[CustomerAddress](#customerAddressOutput)' %}
34
{% assign customeroutput_text = '[CustomerOrders](#customerOrders)' %}
45
{% assign crossref_text = '. See [`orders` input attributes](#orders) for details' %}
56
{% assign productreview_text = '[ProductReviews](#ProductReviews)!' %}
67
{% assign rewardpoints_text = '[RewardPoints](#RewardPoints)' %}
78
{% assign wishlist_text = '[Wishlist](#Wishlist)!' %}
89
{% else %}
10+
{% assign comparelist_text = 'CompareList' %}
911
{% assign customeraddress_text = 'CustomerAddress' %}
1012
{% assign customeroutput_text = '[CustomerOrders]' %}
1113
{% assign crossref_text = '' %}
@@ -18,6 +20,7 @@ Attribute | Data Type | Description
1820
--- | --- | ---
1921
`addresses` | {{ customeraddress_text }} | An array containing the customer's shipping and billing addresses
2022
`allow_remote_shopping_assistance` | Boolean! | Indicates whether the customer has enabled remote shopping assistance
23+
`compare_list` | CompareList | The contents of the customer's compare list
2124
`created_at` | String | Timestamp indicating when the account was created
2225
`date_of_birth` | String | The customer's date of birth. In keeping with current security and privacy best practices, be sure you are aware of any potential legal and security risks associated with the storage of customers’ full date of birth (month, day, year) along with other personal identifiers, such as full name, before collecting or processing such data.
2326
`default_billing` | String | The ID assigned to the billing address
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
group: graphql
3+
title: addProductsToCompareList mutation
4+
contributor_name: Atwix
5+
contributor_link: https://www.atwix.com/
6+
---
7+
8+
The `addProductsToCompareList` mutation adds products to the comparison list.
9+
10+
You must specify the unique ID of the compare list as well as a list of product IDs to be added to the comparison list.
11+
12+
## Syntax
13+
14+
```graphql
15+
mutation {
16+
addProductsToCompareList(
17+
input: AddProductsToCompareListInput
18+
) {
19+
CompareList
20+
}
21+
}
22+
```
23+
24+
## Example usage
25+
26+
The following example shows how to add two products into the existing comparison list with unique ID "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD".
27+
28+
**Request:**
29+
30+
```graphql
31+
mutation {
32+
addProductsToCompareList(
33+
input: {
34+
uid: "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD",
35+
products: ["3", "4"]
36+
}
37+
) {
38+
uid
39+
item_count
40+
attributes {
41+
code
42+
label
43+
}
44+
items {
45+
uid
46+
product {
47+
sku
48+
name
49+
description {
50+
html
51+
}
52+
}
53+
}
54+
}
55+
}
56+
```
57+
58+
**Response:**
59+
60+
```json
61+
{
62+
"data": {
63+
"addProductsToCompareList": {
64+
"uid": "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD",
65+
"item_count": 4,
66+
"attributes": [
67+
{
68+
"code": "sku",
69+
"label": "SKU"
70+
},
71+
{
72+
"code": "description",
73+
"label": "Description"
74+
},
75+
{
76+
"code": "short_description",
77+
"label": "Short Description"
78+
},
79+
{
80+
"code": "activity",
81+
"label": "Activity"
82+
}
83+
],
84+
"items": [
85+
{
86+
"uid": "1",
87+
"product": {
88+
"sku": "24-MB01",
89+
"name": "Joust Duffle Bag",
90+
"description": {
91+
"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>"
92+
}
93+
}
94+
},
95+
{
96+
"uid": "2",
97+
"product": {
98+
"sku": "24-MB04",
99+
"name": "Strive Shoulder Pack",
100+
"description": {
101+
"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>"
102+
}
103+
}
104+
},
105+
{
106+
"uid": "3",
107+
"product": {
108+
"sku": "24-MB03",
109+
"name": "Crown Summit Backpack",
110+
"description": {
111+
"html": "<p>The Crown Summit Backpack is equally at home in a gym locker, study cube or a pup tent, so be sure yours is packed with books, a bag lunch, water bottles, yoga block, laptop, or whatever else you want in hand. Rugged enough for day hikes and camping trips, it has two large zippered compartments and padded, adjustable shoulder straps.</p>\n<ul>\n<li>Top handle.</li>\n<li>Grommet holes.</li>\n<li>Two-way zippers.</li>\n<li>H 20\" x W 14\" x D 12\".</li>\n<li>Weight: 2 lbs, 8 oz. Volume: 29 L.</li>\n<ul>"
112+
}
113+
}
114+
},
115+
{
116+
"uid": "4",
117+
"product": {
118+
"sku": "24-MB05",
119+
"name": "Wayfarer Messenger Bag",
120+
"description": {
121+
"html": "<p>Perfect for class, work or the gym, the Wayfarer Messenger Bag is packed with pockets. The dual-buckle flap closure reveals an organizational panel, and the roomy main compartment has spaces for your laptop and a change of clothes. An adjustable shoulder strap and easy-grip handle promise easy carrying.</p>\n<ul>\n<li>Multiple internal zip pockets.</li>\n<li>Made of durable nylon.</li>\n</ul>"
122+
}
123+
}
124+
}
125+
]
126+
}
127+
}
128+
}
129+
```
130+
131+
## Input attributes
132+
133+
The `AddProductsToCompareListInput` input object defines the product IDs to be compared within an existing comparison list.
134+
135+
### AddProductsToCompareListInput attributes {#addProductsToCompareListInput}
136+
137+
The `AddProductsToCompareListInput` object contains the following attributes:
138+
139+
Attribute | Data Type | Description
140+
--- | --- | ---
141+
`products` | [ID]! | An array of product IDs to add to the compare list
142+
`uid` | ID! | The unique ID of a `CompareList` object
143+
144+
## Output attributes
145+
146+
The `CompareList` output object contains the following attribute:
147+
148+
{% include graphql/compare-list-output.md %}
149+
150+
## Related topics
151+
152+
* [compareList query]({{page.baseurl}}/graphql/queries/compare-list.html)
153+
* [assignCompareListToCustomer mutation]({{page.baseurl}}/graphql/mutations/assign-compare-list-to-customer.html)
154+
* [createCompareList mutation]({{page.baseurl}}/graphql/mutations/create-compare-list.html)
155+
* [deleteCompareList mutation]({{page.baseurl}}/graphql/mutations/delete-compare-list.html)
156+
* [removeProductsFromCompareList mutation]({{page.baseurl}}/graphql/mutations/remove-products-from-compare-list.html)

0 commit comments

Comments
 (0)