wishlists
نظرة عامة
اجلب جميع قوائم الرغبات للزائر الحالي بواسطة sessionId أو للمستخدم المسجل بواسطة accountId. تحتوي كل قائمة رغبات على تفاصيل المنتج الكاملة.
- النوع: GraphQL Query
- Endpoint: https://subdomain.com
- المصادقة:
Authorization: Bearer <TOKEN>(مطلوب لـaccountId)
Query
query GetAllWishlists($sessionId: String, $accountId: String) {
getAllWishlists(sessionId: $sessionId, accountId: $accountId) {
success
message
data {
_id
accountId
sessionId
app
products {
_id
title
slug
description
app
tags
status
publishedAt
images { _id fileUrl }
collections {
_id
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
}
}
createdAt
updatedAt
}
}
}
المتغيرات
قدم إما sessionId، accountId، أو كليهما حسب حالة الاستخدام الخاصة بك.
{
"sessionId": "<SESSION_ID>",
"accountId": "<ACCOUNT_ID>"
}
أمثلة
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com\
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "query GetAllWishlists($sessionId: String, $accountId: String) { getAllWishlists(sessionId: $sessionId, accountId: $accountId) { success message data { _id accountId sessionId products { _id title slug } } } }",
"variables": { "sessionId": "<SESSION_ID>", "accountId": "<ACCOUNT_ID>" }
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `
query GetAllWishlists($sessionId: String, $accountId: String) {
getAllWishlists(sessionId: $sessionId, accountId: $accountId) {
success
message
data { _id accountId sessionId products { _id title slug } }
}
}
`,
variables: { sessionId: '<SESSION_ID>', accountId: '<ACCOUNT_ID>' },
}),
});
const json = await res.json();
ملاحظات
- للمستخدمين الزوار، مرر
sessionId؛ للمستخدمين المسجلين، مررaccountIdمع رمز صالح. - عدّل الحقول الفرعية للمنتج حسب الحاجة لتحسين حجم البيانات.