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

ISSUE-7374: The topics for the "Compare List" mutations have been created #8644

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/_data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ pages:
url: /graphql/queries/company.html
edition: b2b-only
exclude_versions: ["2.3"]


- label: compareList query
url: /graphql/queries/compare-list.html
exclude_versions: ["2.3"]

- label: countries query
url: /graphql/queries/directory-countries.html

Expand Down Expand Up @@ -181,6 +185,10 @@ pages:
- label: addDownloadableProductsToCart mutation
url: /graphql/mutations/add-downloadable-products.html

- label: addProductsToCompareList mutation
url: /graphql/mutations/add-products-to-compare-list.html
exclude_versions: ["2.3"]

- label: addProductsToRequisitionList mutation
url: /graphql/mutations/add-products-to-requisition-list.html
edition: b2b-only
Expand Down Expand Up @@ -227,6 +235,10 @@ pages:
url: /graphql/mutations/apply-store-credit.html
edition: ee-only

- label: assignCompareListToCustomer mutation
url: /graphql/mutations/assign-compare-list-to-customer.html
exclude_versions: ["2.3"]

- label: changeCustomerPassword mutation
url: /graphql/mutations/change-customer-password.html

Expand Down Expand Up @@ -268,6 +280,10 @@ pages:
edition: b2b-only
exclude_versions: ["2.3"]

- label: createCompareList mutation
url: /graphql/mutations/create-compare-list.html
exclude_versions: [ "2.3" ]

- label: createCustomer mutation
url: /graphql/mutations/create-customer.html

Expand Down Expand Up @@ -320,6 +336,10 @@ pages:
edition: b2b-only
exclude_versions: ["2.3"]

- label: deleteCompareList mutation
url: /graphql/mutations/delete-compare-list.html
exclude_versions: [ "2.3" ]

- label: deleteCustomerAddress mutation
url: /graphql/mutations/delete-customer-address.html

Expand Down Expand Up @@ -371,6 +391,10 @@ pages:
url: /graphql/mutations/redeem-giftcard-balance.html
edition: ee-only

- label: removeProductsFromCompareList mutation
url: /graphql/mutations/remove-products-from-compare-list.html
exclude_versions: ["2.3"]

- label: removeCouponFromCart mutation
url: /graphql/mutations/remove-coupon.html

Expand Down
34 changes: 34 additions & 0 deletions src/_includes/graphql/compare-list-output.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Attribute | Data Type | Description
--- | --- | ---
`attributes` | [[ComparableAttribute]](#comparableAttributeObjectOutput) | An array of attributes that can be used for comparing products
`item_count` | Int! | The number of items in the compare lists
`items` | [[ComparableItem]](#comparableItemObjectOutput) | An array of products to compare
`uid` | ID! | The unique ID of a `CompareList` object

### ComparableAttribute object {#comparableAttributeObjectOutput}

The `ComparableAttribute` object outputs attributes which available to comparison:

Attribute | Data Type | Description
--- | --- | ---
`code` | String! | An attribute code that is enabled for product comparisons
`label` | String! | The label of the attribute code.

### ComparableItem object {#comparableItemObjectOutput}

The `ComparableItem` object outputs items that have been added to compare list:

Attribute | Data Type | Description
--- | --- | ---
`attributes` | [[ProductAttribute]!](#productAttributeObjectOutput) | An array of product attributes that can be used to compare products
`product` | [ProductInterface!]({{ page.baseurl }}/graphql/interfaces/product-interface.html) | Contains details about a product in a compare list
`uid` | ID! | The unique ID of a `ComparableItem` object

### ProductAttribute object {#productAttributeObjectOutput}

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
3 changes: 3 additions & 0 deletions src/_includes/graphql/customer-output-24.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% if page.url contains 'graphql/queries/customer.html' %}
{% assign comparelist_text = " '[CompareList](#CompareList)' %}
{% assign customeraddress_text = '[CustomerAddress](#customerAddressOutput)' %}
{% assign customeroutput_text = '[CustomerOrders](#customerOrders)' %}
{% assign crossref_text = '. See [`orders` input attributes](#orders) for details' %}
{% assign productreview_text = '[ProductReviews](#ProductReviews)!' %}
{% assign rewardpoints_text = '[RewardPoints](#RewardPoints)' %}
{% assign wishlist_text = '[Wishlist](#Wishlist)!' %}
{% else %}
{% assign comparelist_text = 'CompareList' %}
{% assign customeraddress_text = 'CustomerAddress' %}
{% assign customeroutput_text = '[CustomerOrders]' %}
{% assign crossref_text = '' %}
Expand All @@ -18,6 +20,7 @@ Attribute | Data Type | Description
--- | --- | ---
`addresses` | {{ customeraddress_text }} | An array containing the customer's shipping and billing addresses
`allow_remote_shopping_assistance` | Boolean! | Indicates whether the customer has enabled remote shopping assistance
`compare_list` | CompareList | The contents of the customer's compare list
`created_at` | String | Timestamp indicating when the account was created
`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.
`default_billing` | String | The ID assigned to the billing address
Expand Down
156 changes: 156 additions & 0 deletions src/guides/v2.4/graphql/mutations/add-products-to-compare-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
---
group: graphql
title: addProductsToCompareList mutation
contributor_name: Atwix
contributor_link: https://www.atwix.com/
---

The `addProductsToCompareList` mutation adds products to the comparison list.

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.

## Syntax

```graphql
mutation {
addProductsToCompareList(
input: AddProductsToCompareListInput
) {
CompareList
}
}
```

## Example usage

The following example shows how to add two products into the existing comparison list with unique ID "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD".

**Request:**

```graphql
mutation {
addProductsToCompareList(
input: {
uid: "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD",
products: ["3", "4"]
}
) {
uid
item_count
attributes {
code
label
}
items {
uid
product {
sku
name
description {
html
}
}
}
}
}
```

**Response:**

```json
{
"data": {
"addProductsToCompareList": {
"uid": "sssXyGZkTFksdPnxNoK1ut6OiV4bbchD",
"item_count": 4,
"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>"
}
}
},
{
"uid": "3",
"product": {
"sku": "24-MB03",
"name": "Crown Summit Backpack",
"description": {
"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>"
}
}
},
{
"uid": "4",
"product": {
"sku": "24-MB05",
"name": "Wayfarer Messenger Bag",
"description": {
"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>"
}
}
}
]
}
}
}
```

## Input attributes

The `AddProductsToCompareListInput` input object defines the product IDs to be compared within an existing comparison list.

### AddProductsToCompareListInput attributes {#addProductsToCompareListInput}

The `AddProductsToCompareListInput` object contains the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`products` | [ID]! | An array of product IDs to add to the compare list
`uid` | ID! | The unique ID of a `CompareList` object

## Output attributes

The `CompareList` output object contains the following attribute:

{% include graphql/compare-list-output.md %}

## Related topics

* [compareList query]({{page.baseurl}}/graphql/queries/compare-list.html)
* [assignCompareListToCustomer mutation]({{page.baseurl}}/graphql/mutations/assign-compare-list-to-customer.html)
* [createCompareList mutation]({{page.baseurl}}/graphql/mutations/create-compare-list.html)
* [deleteCompareList mutation]({{page.baseurl}}/graphql/mutations/delete-compare-list.html)
* [removeProductsFromCompareList mutation]({{page.baseurl}}/graphql/mutations/remove-products-from-compare-list.html)
Loading