Skip to content
Guides
Queries

collections

List the store's published collections and optionally search or sort the result.

Last updated:

collections returns every published collection visible in the resolved store. Each item includes its public metadata and the number of associated published products.

Signature

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

Arguments

ArgumentTypeDefaultRule
searchStringnullSearches name, slug, description, and type. It is trimmed before searching; an empty value is treated as null. Maximum input length: 200 characters.
sortNavigationSearchSortnullWhen omitted, results are sorted by name ascending.

The sort argument accepts these exact values:

ValueEffective collection order
DEFAULTName ascending.
NAME_ASCName ascending.
NAME_DESCName descending.
ORDER_ASCName ascending at present.
ORDER_DESCName ascending at present.
NEWESTCreation descending, then name ascending.
UPDATED_DESCLast update descending, then name ascending.

ORDER_ASC and ORDER_DESC belong to the shared navigation enum, but collections do not currently have a manual order field in their public index.

CollectionItem fields

FieldTypeDescription
idString!Opaque public collection identifier.
slugString!Public slug used in the collection URL.
nameString!Public name.
descriptionStringPublic description, or null when empty.
imageUrlStringPublic image URL, or null when absent.
typeString!Collection type stored by the catalog.
productCountInt!Number of associated published products in the current store.

Query

Collections.graphql
query Collections($search: String, $sort: NavigationSearchSort) {
  collections(search: $search, sort: $sort) {
    id
    slug
    name
    description
    imageUrl
    type
    productCount
  }
}

Variables

Variables
{
  "search": "summer",
  "sort": "NAME_ASC"
}

Enums are sent as strings inside the JSON variables object.

cURL

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

Response
{
  "data": {
    "collections": [
      {
        "id": "collection-1",
        "slug": "summer",
        "name": "Summer",
        "description": null,
        "imageUrl": null,
        "type": "Manual",
        "productCount": 2
      }
    ]
  }
}

A store with no matching collections returns "collections": [].

Errors

CodeWhen it occurs
BAD_USER_INPUTsearch exceeds 200 characters.
STORE_CONTEXT_REQUIREDx-Store-Domain does not resolve a store.
Search is too long
{
  "errors": [
    {
      "message": "Search must not exceed 200 characters.",
      "path": ["collections"],
      "extensions": {
        "code": "BAD_USER_INPUT"
      }
    }
  ],
  "data": null
}

Read GraphQL errors for the complete envelope handling rules.

REST equivalent

GET /v1/collections exposes the same list and accepts the REST filters documented in its reference.

On this page