Queries
collections
The store's published collections, with search, sorting and their first products.
collections returns the store's published collections, with their product count and, when you ask for them, their first products.
collections(search: String, sort: NavigationSearchSort, limit: Int): [CollectionItem!]Arguments
| Argument | Type | Default | Rule |
|---|---|---|---|
search | String | — | Searches name, slug, description and type. Up to 200 characters. |
sort | NavigationSearchSort | Name ascending | See the table below. |
limit | Int | All | 1 to 100. Out-of-range values are clamped to the nearest bound. |
NavigationSearchSort
| Value | Order |
|---|---|
DEFAULT, NAME_ASC, ORDER_ASC, ORDER_DESC | Name, A to Z. |
NAME_DESC | Name, Z to A. |
NEWEST | Newest first; ties sorted by name. |
UPDATED_DESC | Most recently updated first; ties sorted by name. |
CollectionItem
| Field | Type | Description |
|---|---|---|
id | String! | Collection ID. |
slug | String! | Slug in the collection URL. |
name | String! | Name. |
description | String | Description, or null when empty. |
imageUrl | String | Image URL, or null. |
type | String! | Collection type, for example Manual. |
productCount | Int! | Published products in the collection. |
template | String | Template assigned in the theme. |
products | [ProductSummary!]! | First products. See Products in each collection. |
Example
query Collections($search: String, $sort: NavigationSearchSort) {
collections(search: $search, sort: $sort) {
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 Collections($search: String, $sort: NavigationSearchSort) { collections(search: $search, sort: $sort) { id slug name description imageUrl type productCount } }",
"variables": { "search": "summer", "sort": "NAME_ASC" }
}'{
"data": {
"collections": [
{
"id": "7204558912004325401",
"slug": "summer",
"name": "Summer",
"description": null,
"imageUrl": null,
"type": "Manual",
"productCount": 2
}
]
}
}With no matches, collections comes back as [].
Products in each collection
products returns each collection's first products, without pagination or facets.
products(limit: Int, sort: ProductSearchSort): [ProductSummary!]!| Argument | Type | Default | Rule |
|---|---|---|---|
limit | Int | 8 | 1 to 24. Out-of-range values are clamped to the nearest bound. |
sort | ProductSearchSort | Collection order | Without a value or with DEFAULT, it keeps the collection's order, including manual order. Values are listed in Schema and types. |
The result matches the first page of products with collectionId set to the collection id and pageSize set to limit. To paginate or filter, use products(input: { collectionId }).
query CollectionsWithProducts($limit: Int, $productLimit: Int) {
collections(limit: $limit) {
id
slug
name
products(limit: $productLimit) {
id
name
slug
imageUrl
price
compareAtPrice
}
}
}{
"limit": 4,
"productLimit": 8
}{
"data": {
"collections": [
{
"id": "7204558912004325401",
"slug": "summer",
"name": "Summer",
"products": [
{
"id": "456",
"name": "Mug",
"slug": "mug",
"imageUrl": "/mug.jpg",
"price": 10,
"compareAtPrice": null
}
]
}
]
}
}Errors
| Code | Cause |
|---|---|
BAD_USER_INPUT | search is longer than 200 characters. |
STORE_CONTEXT_REQUIRED | x-Store-Domain is missing or doesn't match a store. |
REST equivalent
GET / returns the same list, without limit or products.
Last updated: