Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.
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
4 changes: 2 additions & 2 deletions _data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pages:
- label: Other objects
children:

- label: CMS endpoints
- label: CMS endpoint
url: /graphql/reference/cms.html

- label: CustomAttributeMetadata endpoint
Expand All @@ -83,7 +83,7 @@ pages:
- label: Store endpoint
url: /graphql/reference/store-config.html

- label: urlResolver endpoint
- label: UrlRewrite endpoint
url: /graphql/reference/url-resolver.html

- label: Wishlist endpoint
Expand Down
15 changes: 11 additions & 4 deletions guides/v2.3/graphql/reference/products.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ products(
sort: ProductSortInput
): Products
```

Each query attribute is defined below:

Attribute | Description
Expand Down Expand Up @@ -49,7 +50,7 @@ Magento processes the attribute values specified in a `ProductFilterInput` as

The following attributes can be used to create filters. See the [Response](#Response) section for information about each attribute.

```
``` text
country_of_manufacture
created_at
custom_design
Expand Down Expand Up @@ -87,6 +88,8 @@ thumbnail
thumbnail_label
tier_price
updated_at
url_key
url_path
weight
```

Expand Down Expand Up @@ -114,13 +117,13 @@ content="GraphQL automatically filters out a product attribute if ALL of the fol

The system returns a `Products` object containing the following information:

{% highlight json %}
``` text
items: [ProductInterface]
page_info: SearchResultPageInfo
total_count: Int
filters: [LayerFilter]
sort_fields: SortFields
{% endhighlight %}
```

Each attribute is described below:

Expand All @@ -145,6 +148,7 @@ When a product requires a filter attribute that is not a field on its output sch
</arguments>
</type>
```

This example adds `field_to_sort` and `other_field_to_sort` attributes to the `additionalAttributes` array defined in the `ProductEntityAttributesForAst` class. The array already contains the `min_price`, `max_price`, and `category_ids` attributes.

## ProductInterface {#ProductInterface}
Expand Down Expand Up @@ -206,6 +210,9 @@ Attribute | Data type | Description
`tier_prices` | [ProductTierPrices] | An array of [ProductTierPrices](#ProductTier) objects
`type_id` | String | One of `simple`, `virtual`, `bundle`, `downloadable`,`grouped`, `configurable`
`updated_at` | String | The timestamp indicating when the product was last updated
`url_key` | String | The part of the URL that identifies the product. This attribute is defined in the `CatalogUrlRewrite` module
`url_path` | String | The part of the URL that precedes the `url_key`. This attribute is defined in the `CatalogUrlRewrite` module
`url_rewrites` | [UrlRewrite] | A list of URL rewrites. See [UrlRewrite endpoint]({{ page.baseurl }}/graphql/reference/url-resolver.html#UrlRewrite) for more information and an example query
`website_ids` | [Int] | An array of website IDs in which the product is available
{:style="table-layout:auto;"}

Expand Down Expand Up @@ -342,7 +349,7 @@ Field | Type | Description

### LayerFilterItemInterface

`LayerFilterItemInterface ` contains an array of items that match the terms defined in the filter.
`LayerFilterItemInterface` contains an array of items that match the terms defined in the filter.

Field | Type | Description
--- | --- | ---
Expand Down
128 changes: 120 additions & 8 deletions guides/v2.3/graphql/reference/url-resolver.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,54 @@
---
group: graphql
title: urlResolver endpoint
title: UrlRewrite endpoint
---

The `urlResolver` query returns the canonical URL for a specified product, category or CMS page. An external app can render a page by a url without any prior knowledge about the landing page.
A merchant can reconfigure (rewrite) the URL to any product, category, or CMS page. When the rewrite goes into effect, any links that point to the previous URL are redirected to the new address.

## Query structure
## Query

`urlResolver(url: String!): EntityUrl`
The `urlResolver` query returns the canonical URL for a specified product, category or CMS page. An external app can render a page by a URL without any prior knowledge about the landing page.

where:
### Syntax

`{urlResolver(url: String!): EntityUrl}`

### EntityUrl attributes

The `EntityUrl` output object contains the `id`, `canonical_url`, and `type` attributes.

Attribute | Data Type | Description
--- | --- | ---
`url` | String | The URL to resolve. Magento stores product and category URLs with the `.html` extension. CMS URLs do not contain the extension.
`EntityUrl` | `EntityUrl` | An output object containing the `id`, `canonical_url`, and `type` attributes.
`id` | Int | The ID assigned to the object associated with the specified `url`. This could be a product ID, category ID, or page ID.

`canonical_url` | String | The internal relative URL. If the specified `url` is a redirect, the query returns the redirected URL, not the original.
`id` | Int | The ID assigned to the object associated with the specified `url`. This could be a product ID, category ID, or page ID.
`type` | UrlRewriteEntityTypeEnum | The value of `UrlRewriteEntityTypeEnum` is one of PRODUCT, CATEGORY, or CMS_PAGE.
`url` | String | The URL to resolve. Magento stores product and category URLs with the `.html` extension. CMS URLs do not contain the extension.

### UrlRewrite object {#UrlRewrite}

The `products` query can request details about the `UrlRewrite` object.

Field | Type | Description
--- | --- | ---
`parameters` | [[`HttpQueryParameter`]](#HttpQueryParameter) | An array of target path parameters
`url` | String | The request URL
{:style="table-layout:auto;"}

### HttpQueryParameter object {#HttpQueryParameter}

The `HttpQueryParameter` object provides details about target path parameters.

Field | Type | Description
--- | --- | ---
`name` | String | The parameter name, such as `id`
`value` | String | The value assigned to the parameter
{:style="table-layout:auto;"}

## Example usage

The following query returns information about the URL containing `joust-duffle-bag.html`.

**Request**

``` text
Expand All @@ -47,3 +74,88 @@ Attribute | Data Type | Description
}
}
```

The following product query returns URL rewrite information about the Joust Duffle Bag.

**Request**

``` text
{
products(search: "Joust") {
items {
name
sku
url_rewrites {
url
parameters {
name
value
}
}
}
}
}
```

**Response**

```json
{
"data": {
"products": {
"items": [
{
"name": "Joust Duffle Bag",
"sku": "24-MB01",
"url_rewrites": [
{
"url": "no-route",
"parameters": [
{
"name": "page_id",
"value": "1"
}
]
},
{
"url": "joust-duffle-bag.html",
"parameters": [
{
"name": "id",
"value": "1"
}
]
},
{
"url": "gear/joust-duffle-bag.html",
"parameters": [
{
"name": "id",
"value": "1"
},
{
"name": "category",
"value": "3"
}
]
},
{
"url": "gear/bags/joust-duffle-bag.html",
"parameters": [
{
"name": "id",
"value": "1"
},
{
"name": "category",
"value": "4"
}
]
}
]
}
]
}
}
}
```