Skip to content
Queries

route

What is published at a store path: a product, category, brand, collection or redirect.

route tells you what is published at a store path and returns it in full. Use it in your frontend's catch-all route.

route(path: String!, previewKey: String): UrlResolution

Arguments

ArgumentTypeRule
pathString!The path, without domain or query. An empty one returns BAD_USER_INPUT.
previewKeyStringThe key from the admin preview link. With a valid key, an unpublished product also comes back.

If nothing matches, route is null.

UrlResolution

FieldTypeDescription
kindString!product, category, brand, collection or redirect.
urlString!The resource's current URL.
handleStringThe resource slug. null with redirect.
productProductDetailThe product page data, with kind: "product". See product.
categoryCategoryDetailThe category, with kind: "category".
brandBrandDetailThe brand, with kind: "brand". See brand.
collectionCollectionItemThe collection, with kind: "collection". See collections.
  • With redirect, redirect to url with a 301. It happens with old URLs, uppercase paths or a trailing /.
  • An unpublished product that comes with previewKey has isPreview: true: don't cache it or index it.

CategoryDetail

FieldTypeDescription
idString!Category ID.
nameString!Name.
slugString!Slug.
urlString!Public path of the category.
descriptionStringDescription.
imageUrlStringImage.
metaTitleStringTitle for search engines.
metaDescriptionStringDescription for search engines.
parentIdStringID of the parent category.
productCountInt!Number of products.
ancestors[CategoryLink!]!From the root to the parent, for breadcrumbs.
children[CategoryItem!]!Subcategories.
products(input: StorefrontProductsInput)SearchResult!Products in the category and its subcategories.

products takes the same input as products and ignores categories.

TypeFields
CategoryLinkid: String!, name: String!, url: String!
CategoryItemid: String!, name: String!, slug: String!, url: String!, imageUrl: String, parentId: String, path: String!, order: Int!, productCount: Int!

Example

Route.graphql
query Route($path: String!) {
  route(path: $path) {
    kind
    url
    product { id name price }
    category {
      id
      name
      ancestors { name url }
      products(input: { pageSize: 24, includeFilters: false }) {
        totalPages
        products { id name url imageUrl price }
      }
    }
    brand { id name }
    collection { id name }
  }
}
Terminal
curl --request POST "https://storefront.ecomiq.pe/graphql" \
  --header "Content-Type: application/json" \
  --header "x-Store-Domain: my-store" \
  --data-binary '{
    "query": "query Route($path: String!) { route(path: $path) { kind url product { id name price } category { id name ancestors { name url } products(input: { pageSize: 24, includeFilters: false }) { totalPages products { id name url imageUrl price } } } brand { id name } collection { id name } } }",
    "variables": { "path": "/categories/t-shirts" }
  }'
Response
{
  "data": {
    "route": {
      "kind": "category",
      "url": "/categories/t-shirts",
      "product": null,
      "category": {
        "id": "7204558912004327982",
        "name": "T-shirts",
        "ancestors": [{ "name": "Men", "url": "/categories/men" }],
        "products": {
          "totalPages": 1,
          "products": [
            {
              "id": "7204558912004322039",
              "name": "Pima cotton T-shirt",
              "url": "/products/pima-cotton-t-shirt",
              "imageUrl": "https://…/t-shirt.webp",
              "price": 59.9
            }
          ]
        }
      },
      "brand": null,
      "collection": null
    }
  }
}

Errors

CodeCause
BAD_USER_INPUTpath is empty.
STORE_CONTEXT_REQUIREDx-Store-Domain is missing or doesn't match a store.

REST equivalent

GET /v1/urls/resolve returns the same, without the fields that only GraphQL has, such as products or related. If nothing matches, it returns 404 Url.NotFound.

Last updated:

On this page