Skip to content
Queries

collections

The store's published collections, with search, sorting and their first products.

collections returns the store's published collections, with their product count and, when you ask for them, their first products.

collections(search: String, sort: NavigationSearchSort, limit: Int): [CollectionItem!]

Arguments

ArgumentTypeDefaultRule
searchString—Searches name, slug, description and type. Up to 200 characters.
sortNavigationSearchSortName ascendingSee the table below.
limitIntAll1 to 100. Out-of-range values are clamped to the nearest bound.
ValueOrder
DEFAULT, NAME_ASC, ORDER_ASC, ORDER_DESCName, A to Z.
NAME_DESCName, Z to A.
NEWESTNewest first; ties sorted by name.
UPDATED_DESCMost recently updated first; ties sorted by name.

CollectionItem

FieldTypeDescription
idString!Collection ID.
slugString!Slug in the collection URL.
nameString!Name.
descriptionStringDescription, or null when empty.
imageUrlStringImage URL, or null.
typeString!Collection type, for example Manual.
productCountInt!Published products in the collection.
templateStringTemplate assigned in the theme.
products[ProductSummary!]!First products. See Products in each collection.

Example

Collections.graphql
query Collections($search: String, $sort: NavigationSearchSort) {
  collections(search: $search, sort: $sort) {
    id
    slug
    name
    description
    imageUrl
    type
    productCount
  }
}
Terminal
curl --request POST "https://storefront.ecomiq.pe/graphql" \
  --header "Content-Type: application/json" \
  --header "x-Store-Domain: my-store" \
  --data-binary '{
    "query": "query Collections($search: String, $sort: NavigationSearchSort) { collections(search: $search, sort: $sort) { id slug name description imageUrl type productCount } }",
    "variables": { "search": "summer", "sort": "NAME_ASC" }
  }'
Response
{
  "data": {
    "collections": [
      {
        "id": "7204558912004325401",
        "slug": "summer",
        "name": "Summer",
        "description": null,
        "imageUrl": null,
        "type": "Manual",
        "productCount": 2
      }
    ]
  }
}

With no matches, collections comes back as [].

Products in each collection

products returns each collection's first products, without pagination or facets.

products(limit: Int, sort: ProductSearchSort): [ProductSummary!]!
ArgumentTypeDefaultRule
limitInt81 to 24. Out-of-range values are clamped to the nearest bound.
sortProductSearchSortCollection orderWithout a value or with DEFAULT, it keeps the collection's order, including manual order. Values are listed in Schema and types.

The result matches the first page of products with collectionId set to the collection id and pageSize set to limit. To paginate or filter, use products(input: { collectionId }).

CollectionsWithProducts.graphql
query CollectionsWithProducts($limit: Int, $productLimit: Int) {
  collections(limit: $limit) {
    id
    slug
    name
    products(limit: $productLimit) {
      id
      name
      slug
      imageUrl
      price
      compareAtPrice
    }
  }
}
Variables
{
  "limit": 4,
  "productLimit": 8
}
Response
{
  "data": {
    "collections": [
      {
        "id": "7204558912004325401",
        "slug": "summer",
        "name": "Summer",
        "products": [
          {
            "id": "456",
            "name": "Mug",
            "slug": "mug",
            "imageUrl": "/mug.jpg",
            "price": 10,
            "compareAtPrice": null
          }
        ]
      }
    ]
  }
}

Errors

CodeCause
BAD_USER_INPUTsearch is longer than 200 characters.
STORE_CONTEXT_REQUIREDx-Store-Domain is missing or doesn't match a store.

REST equivalent

GET /v1/collections returns the same list, without limit or products.

Last updated:

On this page