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
| Argument | Type | Rule |
|---|---|---|
slug | String! | Required. It is trimmed before lookup, cannot be empty, and accepts at most 200 characters. |
CollectionItem fields
| Field | Type | Description |
|---|---|---|
id | String! | Opaque public collection identifier. |
slug | String! | Public slug used in the collection URL. |
name | String! | Public name. |
description | String | Public description, or null when empty. |
imageUrl | String | Public image URL, or null when absent. |
type | String! | Collection type stored by the catalog. |
productCount | Int! | Number of associated published products in the current store. |
Query
query Collection($slug: String!) {
collection(slug: $slug) {
id
slug
name
description
imageUrl
type
productCount
}
}Variables
{
"slug": "summer"
}Use variables for the slug; do not interpolate user input into the GraphQL document.
cURL
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": "collection-1",
"slug": "summer",
"name": "Summer",
"description": null,
"imageUrl": null,
"type": "Manual",
"productCount": 2
}
}
}Errors
| Code | When it occurs |
|---|---|
BAD_USER_INPUT | slug is empty or exceeds 200 characters. |
NOT_FOUND | The collection does not exist or is not visible in the resolved store. |
STORE_CONTEXT_REQUIRED | x-Store-Domain does not resolve a store. |
{
"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.