products
نظرة عامة
اجلب قائمة مُرقمة من المنتجات. يمكنك تخصيص الحقول المُعادة وفقاً لاحتياجات واجهتك.
- النوع: GraphQL Query
- Endpoint: https://subdomain.com
- المصادقة:
Authorization: Bearer <TOKEN>
Query
query FindAllProducts($input: GetAllProductsInput) {
findAllProducts(input: $input) {
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 {
total
page
limit
totalPages
}
}
}
المتغيرات
{
"input": {
"page": 1,
"limit": 20
// أضف مرشحات/ترتيب اختياري إذا كان API الخاص بك يدعمها
}
}
أمثلة
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "query FindAllProducts($input: GetAllProductsInput) { findAllProducts(input: $input) { success message data { _id title slug } pagination { total page limit totalPages } } }",
"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 FindAllProducts($input: GetAllProductsInput) {
findAllProducts(input: $input) {
success
message
data { _id title slug }
pagination { total page limit totalPages }
}
}
`,
variables: { input: { page: 1, limit: 20 } },
}),
});
const json = await res.json();
ملاحظات
- استبدل
<TOKEN>برمز صالح. - أضف/احذف الحقول داخل
dataوpaginationوفقاً لما تعرضه. - إذا كان
GetAllProductsInputيدعم المرشحات (مثل النص، المجموعة، الوسوم، الحالة)، مررها داخلinput.