RoutableInterface attributes
Some entities are "routable", meaning that they have URLs and can serve as the model for a rendered page. The following implementations of the RoutableInterface
allow you to return details in the route
query. RoutableUrl
is returned when the URL is not linked to an entity.
- BundleProduct
- CategoryTree
- CmsPage
- ConfigurableProduct
- DownloadableProduct
- GiftCardProduct
- GroupedProduct
- SimpleProduct
- VirtualProduct
- RoutableUrl
Routable URL
RoutableUrl
is the default implementation of RoutableInterface. This type is returned when the URL is not linked to a product or CMS page or to a category. As a result, the RoutableUrl.type
field always returns null
.
Sample queries
Return information about a URL key
The following query returns information about the specified URL key. The query contains multiple fragments so that it can be used for categories, CMS pages, and multiple product types.
Request:
Copied to your clipboard{route(url: "teton-pullover-hoodie.html") {__typenamerelative_urlredirect_codetype... on SimpleProduct {skuurl_keyuidurl_rewrites {urlparameters {namevalue}}}... on ConfigurableProduct {skuimage {label}uidurl_keyurl_suffixurl_rewrites {parameters {namevalue}}media_gallery {url}}... on CategoryTree {uidproduct_countcanonical_urlproducts {total_countitems {skuuid}}}... on CmsPage {contentcontent_headingmeta_titlemeta_keywordsmeta_descriptionpage_layoutidentifiertitleurl_key}... on GroupedProduct {canonical_urlskuitems {product {uidurl_key}}}... on BundleProduct {items {skurequiredtypetitleoptions {uidis_defaultcan_change_quantityprice_typequantity}}}}}
Response:
Copied to your clipboard{"data": {"route": {"__typename": "ConfigurableProduct","relative_url": "teton-pullover-hoodie.html","redirect_code": 0,"type": "PRODUCT","sku": "MH02","image": {"label": "Teton Pullover Hoodie"},"uid": "ODY=","url_key": "teton-pullover-hoodie","url_suffix": ".html","url_rewrites": [{"parameters": [{"name": "id","value": "86"}]},{"parameters": [{"name": "id","value": "86"},{"name": "category","value": "16"}]},{"parameters": [{"name": "id","value": "86"},{"name": "category","value": "13"}]}],"media_gallery": [{"url": "http://example.com/media/catalog/product/cache/3103a735c131a485a1ff51c24439c39b/m/h/mh02-black_main_1.jpg"},{"url": "http://example.com/media/catalog/product/cache/3103a735c131a485a1ff51c24439c39b/m/h/mh02-black_alt1_1.jpg"},{"url": "http://example.com/media/catalog/product/cache/3103a735c131a485a1ff51c24439c39b/m/h/mh02-black_back_1.jpg"}]}}}
Find the external redirect URL
In the following example, an internal URL support.html
is configured to redirect to an external URL https://support.example.com/
using URL Rewrite.
Request:
Copied to your clipboard{route(url: "support.html") {__typenamerelative_urlredirect_codetype}}
Response:
Copied to your clipboard{"data": {"route": {"__typename": "RoutableUrl","relative_url": "https://support.example.com/","redirect_code": 302,"type": null}}}