collections
نظرة عامة
اجلب قائمة مُرقمة من المجموعات. يمكنك تخصيص الحقول التي تحتاجها في data و pagination.
- النوع: GraphQL Query
- Endpoint: https://subdomain.com
- المصادقة:
Authorization: Bearer <TOKEN>
Query
query FindAllCollections($input: GetAllCollectionsInput) {
findAllCollections(input: $input) {
success
message
data {
_id
title
slug
description
operation
image {
# أضف الحقول التي تحتاجها، مثل url, alt
}
}
pagination {
# أضف الحقول التي تحتاجها، مثل page, limit, total, pages
}
}
}
المتغيرات
{
"input": {
"page": 1,
"limit": 20
}
}
أمثلة
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "query FindAllCollections($input: GetAllCollectionsInput) { findAllCollections(input: $input) { success message data { _id title slug } pagination { /* add fields */ } } }",
"variables": { "input": { "page": 1, "limit": 20 } }
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `
query FindAllCollections($input: GetAllCollectionsInput) {
findAllCollections(input: $input) {
success
message
data { _id title slug }
pagination { /* add fields */ }
}
}
`,
variables: { input: { page: 1, limit: 20 } },
}),
});
const json = await res.json();
ملاحظات
- استبدل
<TOKEN>برمز صالح. - أضف الحقول الدقيقة التي تحتاجها داخل
image {}وpagination {}. - إذا كان API الخاص بك يفرض مرشحات معينة في
GetAllCollectionsInput، أضفها تحتinputوفقاً لذلك.