collectionProducts
Overview
Fetch a paginated list of products for a given collection handle.
- Type: GraphQL Query
- Endpoint: https://subdomain.com
- Authentication:
Authorization: Bearer <TOKEN>
Query
query GetAllProductsByCollectionHandle($handle: String!) {
getAllProductsByCollectionHandle(handle: $handle) {
success
message
data {
_id
title
slug
description
app
tags
status
publishedAt
images { _id fileUrl }
collections {
_id
app
title
slug
description
operation
image { _id fileUrl }
}
seo { title description keywords image canonicalUrl }
pricing { compareAtPrice originalPrice price }
variantsCount
dimensions { height width unit }
weight { weight unit }
variants {
_id
product
options {
_id
option { name }
label
type
sortOrder
createdAt
updatedAt
}
images { _id fileUrl }
pricing { originalPrice price compareAtPrice }
quantity
weight { unit weight }
}
options {
_id
product
valuesCount
values { _id label type sortOrder createdAt updatedAt }
name
createdAt
updatedAt
}
}
pagination {
totalItems
totalPages
currentPage
limit
hasNextPage
}
}
}
Variables
{
"handle": "<COLLECTION_HANDLE>"
}
Examples
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com \
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "query GetAllProductsByCollectionHandle($handle: String!) { getAllProductsByCollectionHandle(handle: $handle) { success message data { _id title slug } pagination { totalItems totalPages currentPage limit hasNextPage } } }",
"variables": { "handle": "<COLLECTION_HANDLE>" }
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `
query GetAllProductsByCollectionHandle($handle: String!) {
getAllProductsByCollectionHandle(handle: $handle) {
success
message
data { _id title slug }
pagination { totalItems totalPages currentPage limit hasNextPage }
}
}
`,
variables: { handle: '<COLLECTION_HANDLE>' },
}),
});
const json = await res.json();
Notes
- Replace
<TOKEN>and<COLLECTION_HANDLE>with valid values. - Add/remove fields within
dataaccording to your UI needs; the full query above shows a comprehensive shape. - Use the
paginationobject to implement paging controls on the client side.