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
| Argument | Type | Rule |
|---|---|---|
slug | String! | 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
query Collection($slug: String!) {
collection(slug: $slug) {
id
slug
name
description
imageUrl
type
productCount
}
}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" }
}'{
"data": {
"collection": {
"id": "7204558912004325401",
"slug": "summer",
"name": "Summer",
"description": null,
"imageUrl": null,
"type": "Manual",
"productCount": 2
}
}
}Errors
| Code | Cause |
|---|---|
BAD_USER_INPUT | slug is empty or longer than 200 characters. |
NOT_FOUND | The collection doesn't exist in the store or isn't published. |
STORE_CONTEXT_REQUIRED | x-Store-Domain is missing or doesn't match a store. |
REST equivalent
GET / returns the same collection, without products.
Last updated: