Skip to content
Queries

collection

A published collection by slug, with its first products.

collection returns a published collection from the slug in its URL.

collection(slug: String!): CollectionItem!

Arguments

ArgumentTypeRule
slugString!Up to 200 characters. Surrounding spaces are trimmed.

Returns

A CollectionItem, the same type collections returns. Its products(limit, sort) field returns the first products: 8 by default and up to 24. See Products in each collection.

For a collection page with pagination and filters, pass the id from the response to products(input: { collectionId }).

Example

Collection.graphql
query Collection($slug: String!) {
  collection(slug: $slug) {
    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 Collection($slug: String!) { collection(slug: $slug) { id slug name description imageUrl type productCount } }",
    "variables": { "slug": "summer" }
  }'
Response
{
  "data": {
    "collection": {
      "id": "7204558912004325401",
      "slug": "summer",
      "name": "Summer",
      "description": null,
      "imageUrl": null,
      "type": "Manual",
      "productCount": 2
    }
  }
}

Errors

CodeCause
BAD_USER_INPUTslug is empty or longer than 200 characters.
NOT_FOUNDThe collection doesn't exist in the store or isn't published.
STORE_CONTEXT_REQUIREDx-Store-Domain is missing or doesn't match a store.

REST equivalent

GET /v1/collections/{slug} returns the same collection, without products.

Last updated:

On this page