customerSignUp
نظرة عامة
أنشئ ملف تعريف عميل باستخدام CustomerSignupInput. قدم المعرف (بريد إلكتروني/هاتف)، الاسم، الدولة، والنوع لتتوافق مع متطلبات سوقك. تُعيد الاستجابة token للمكالمات المصادق عليها.
- النوع: GraphQL Mutation
- Endpoint: https://subdomain.com
- المصادقة: عادة عامة (بدون رمز) لأن هذا تسجيل جديد
Mutation
mutation CustomerSignup($input: CustomerSignupInput!) {
customerSignup(input: $input) {
success
message
token
}
}
المتغيرات
{
"input": {
"fullname": "محمد أحمد",
"identifier": "user@example.com",
"type": "email",
"country": "SA"
}
}
أمثلة
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com\
-H "Content-Type": "application/json" \
--data-binary @- << 'EOF'
{
"query": "mutation CustomerSignup($input: CustomerSignupInput!) { customerSignup(input: $input) { success message token } }",
"variables": {
"input": {
"fullname": "John Doe",
"identifier": "user@example.com",
"type": "email",
"country": "SA"
}
}
}
EOF
const res = await fetch('https://subdomain.com', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `
mutation CustomerSignup($input: CustomerSignupInput!) {
customerSignup(input: $input) {
success
message
token
}
}
`,
variables: {
input: {
fullname: 'John Doe',
identifier: 'user@example.com',
type: 'email',
country: 'SA',
},
},
}),
});
const json = await res.json();
ملاحظات
- بعض المتاجر تتطلب حقولاً إضافية (كلمة المرور، OTP، الموافقة على التسويق). وسّع
CustomerSignupInputلتطابق الـ backend الخاص بك. - خزّن
tokenالمُعاد بشكل آمن (مثل cookie HTTP-only) لمكالمات GraphQL المصادق عليها اللاحقة. - ادمجه مع
customerLoginإذا كان تدفقك ينشئ حساباً أولاً ثم يسجل الدخول تلقائياً.