customerLogin
Overview
Initiate customer login using CustomerLoginInput. Depending on your backend, this may trigger OTP flows, login links, or return a token immediately.
- Type: GraphQL Mutation
- Endpoint: https://subdomain.com
- Authentication: none required (public login entry point)
Mutation
mutation CustomerLogin($input: CustomerLoginInput!) {
customerLogin(input: $input) {
success
message
token
data
}
}
Variables
{
"input": {
"identifier": "user@example.com",
"type": "email",
"country": "SA"
}
}
identifiercould be email/phone depending ontype. Includecountryif the backend uses it for phone codes or locale.
Examples
- cURL
- JavaScript (fetch)
curl -X POST \
https://subdomain.com\
-H "Content-Type": "application/json" \
--data-binary @- << 'EOF'
{
"query": "mutation CustomerLogin($input: CustomerLoginInput!) { customerLogin(input: $input) { success message token data } }",
"variables": {
"input": {
"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 CustomerLogin($input: CustomerLoginInput!) {
customerLogin(input: $input) {
success
message
token
data
}
}
`,
variables: {
input: {
identifier: 'user@example.com',
type: 'email',
country: 'SA',
},
},
}),
});
const json = await res.json();
Notes
- If the API sends OTP codes,
tokenmight be null until the OTP verification mutation is called. datacan contain extra metadata (e.g., whether the user exists); inspect it per your backend contract.- Securely store any returned
token(e.g., in HTTP-only cookies) for subsequent authenticated calls.