IsEmailAvailableQuery
Description
Checks whether a specified email address has already been used to create a customer account. This query is useful for validating email addresses during the registration process to ensure they are unique.
Endpoint
query isEmailAvailable($email: String!) {
isEmailAvailable(email: $email) {
is_email_available
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| String | Yes | The email address to check for availability. |
Return Values
The query returns an IsEmailAvailableType object with the following field:
| Field | Type | Description |
|---|---|---|
| is_email_available | Boolean | Indicates whether the specified email address is available for use. Returns true if the email is available (not already used by a customer), or false if the email is already in use. |
Usage Example
query {
isEmailAvailable(email: "customer@example.com") {
is_email_available
}
}
Example Response
{
"data": {
"isEmailAvailable": {
"is_email_available": true
}
}
}
Notes
- This query is useful for real-time validation in registration forms to provide immediate feedback to users.
- If the email is already associated with a customer account,
is_email_availablewill befalse. - If the email is not associated with any customer account,
is_email_availablewill betrue. - The query performs a case-insensitive check, so "user@example.com" and "USER@example.com" are considered the same email.
- If an error occurs during the check, the query will default to returning
falsefor safety reasons.