diff --git a/_data/toc/graphql.yml b/_data/toc/graphql.yml index ccfe1befced..d3fb833d5ae 100644 --- a/_data/toc/graphql.yml +++ b/_data/toc/graphql.yml @@ -65,7 +65,7 @@ pages: - label: Other objects children: - - label: CMS endpoints + - label: CMS endpoint url: /graphql/reference/cms.html - label: CustomAttributeMetadata endpoint @@ -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 diff --git a/guides/v2.3/graphql/reference/products.md b/guides/v2.3/graphql/reference/products.md index 24c91a7b304..5bd466a246e 100644 --- a/guides/v2.3/graphql/reference/products.md +++ b/guides/v2.3/graphql/reference/products.md @@ -16,6 +16,7 @@ products( sort: ProductSortInput ): Products ``` + Each query attribute is defined below: Attribute | Description @@ -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 @@ -87,6 +88,8 @@ thumbnail thumbnail_label tier_price updated_at +url_key +url_path weight ``` @@ -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: @@ -145,6 +148,7 @@ When a product requires a filter attribute that is not a field on its output sch ``` + 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} @@ -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;"} @@ -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 --- | --- | --- diff --git a/guides/v2.3/graphql/reference/url-resolver.md b/guides/v2.3/graphql/reference/url-resolver.md index eb2c254cbfc..b37fb6e78a1 100644 --- a/guides/v2.3/graphql/reference/url-resolver.md +++ b/guides/v2.3/graphql/reference/url-resolver.md @@ -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 @@ -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" + } + ] + } + ] + } + ] + } + } +} +``` \ No newline at end of file