Skip to content
Guides
Queries

collection

Retrieve one published collection by slug.

Last updated:

collection returns a published collection visible in the resolved store. Use this query when you already know the collection page slug.

Signature

collection(slug: String!): CollectionItem!

Arguments

ArgumentTypeRule
slugString!Required. It is trimmed before lookup, cannot be empty, and accepts at most 200 characters.

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

Collection.graphql
query Collection($slug: String!) {
  collection(slug: $slug) {
    id
    slug
    name
    description
    imageUrl
    type
    productCount
  }
}

Variables

Variables
{
  "slug": "summer"
}

Use variables for the slug; do not interpolate user input into the GraphQL document.

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 Collection($slug: String!) { collection(slug: $slug) { id slug name description imageUrl type productCount } }",
    "variables": {
      "slug": "summer"
    }
  }'

Response

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

Errors

CodeWhen it occurs
BAD_USER_INPUTslug is empty or exceeds 200 characters.
NOT_FOUNDThe collection does not exist or is not visible in the resolved store.
STORE_CONTEXT_REQUIREDx-Store-Domain does not resolve a store.
Collection not found
{
  "errors": [
    {
      "message": "Collection not found.",
      "path": ["collection"],
      "extensions": {
        "code": "NOT_FOUND"
      }
    }
  ],
  "data": null
}

Read GraphQL errors for the complete envelope handling rules.

REST equivalent

GET /v1/collections/{slug} exposes the same representation through REST.

On this page