Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACP2E-2119: update documentation with new added attribute and examples. #196

Merged
merged 8 commits into from
Mar 26, 2024
135 changes: 134 additions & 1 deletion src/pages/graphql/schema/products/queries/products.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Use `in` to filter on an array of values. For example, to filter on category IDs

#### FilterMatchTypeInput attributes

Use the `FilterMatchTypeInput` object to construct a filter that returns products that partially fuzzy match a string or contain the specified pattern. This object must contain the `match` attribute. Use this attribute to partially fuzzy match the specified string. For example, to filter on a specific SKU, specify a value such as `24-MB01`
Use the `FilterMatchTypeInput` object to construct a filter that returns products that partially match a string or contain the specified pattern. By default, the query returns full matches. You can set the `match_type` field to `PARTIAL` return partial matches.

You must specify a `FilterMatchTypeInput` object to filter on a custom product attribute of the following types:

Expand Down Expand Up @@ -372,6 +372,139 @@ The following sample query returns product by SKU. You have to pass SKU value to
}
```

### Query with filter by `name` attribute and `match_type`

The following sample query returns different results, depending on the value of `match_type`. The default value of `FULL`
indicates the query returns full word matches. If you specify `PARTIAL`, the query performs a partial word search,

**Request:**

```graphql
{
products(filter: { name: { match: "Life", match_type: FULL } }) {
items {
name
sku
url_key
stock_status
price_range {
minimum_price {
regular_price {
value
currency
}
}
}
}
total_count
page_info {
page_size
}
}
}
```

**Response:**

```json
{
"data": {
"products": {
"items": [
{
"name": "Luma Yoga For Life",
"sku": "240-LV09",
"url_key": "luma-yoga-for-life",
"stock_status": "IN_STOCK",
"price_range": {
"minimum_price": {
"regular_price": {
"value": 0,
"currency": "USD"
}
}
}
}
],
"total_count": 1,
"page_info": {
"page_size": 20
}
}
}
}
```

```graphql
{
products(filter: { name: { match: "Life", match_type: PARTIAL } }) {
items {
name
sku
url_key
stock_status
price_range {
minimum_price {
regular_price {
value
currency
}
}
}
}
total_count
page_info {
page_size
}
}
}
```

**Response:**

```json
{
"data": {
"products": {
"items": [
{
"name": "Luma Yoga For Life",
"sku": "240-LV09",
"url_key": "luma-yoga-for-life",
"stock_status": "IN_STOCK",
"price_range": {
"minimum_price": {
"regular_price": {
"value": 0,
"currency": "USD"
}
}
}
},
{
"name": "LifeLong Fitness IV",
"sku": "240-LV05",
"url_key": "lifelong-fitness-iv",
"stock_status": "IN_STOCK",
"price_range": {
"minimum_price": {
"regular_price": {
"value": 14,
"currency": "USD"
}
}
}
}
],
"total_count": 2,
"page_info": {
"page_size": 20
}
}
}
}
```

### Query with layered navigation

The following query returns aggregations for a query that filters on items with these characteristics:
Expand Down
Loading