Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

GraphQL: Add isEmailAvailable query #4556

Merged
merged 3 commits into from
May 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion guides/v2.3/graphql/reference/customer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ The `Customer` endpoint contains information about a customer account accessible
To return or modify information about a customer, Magento recommends you use customer tokens in the header of your GraphQL calls. However, you also can use [session authentication]({{ page.baseurl }}/get-started/authentication/gs-authentication-session.html).

## Queries
Use queries to read server-side data, such as a specific customer's address.

The `customer` query returns information about the logged-in customer.

The `isEmailAvailable` query checks whether the specified email has already been used to create a customer account. A value of `true` indicates the email address is available, and the customer can use the email address to create an account.

### Syntax

`{customer: {Customer}}`

`{isEmailAvailable (email): {IsEmailAvailableOutput}}`

### Customer attributes {#customerAttributes}
The customer object can contain the following attributes:

Expand Down Expand Up @@ -74,6 +79,18 @@ Attribute | Data Type | Description
`region` | String | The state or province name
`region_id` | Int | Uniquely identifies the region

### isEmailAvailable query attribute

Attribute | Data Type | Description
--- | --- | ---
`email` | String! | The email address to check

### IsEmailAvailableOutput attribute

Attribute | Data Type | Description
--- | --- | ---
`is_email_available` | Boolean | A value of `true` indicates the email address is available, and the customer can use the email address to create an account

### Example usage

The following call returns information about the logged-in customer. Provide the customer's token in the header section of the query.
Expand Down Expand Up @@ -140,6 +157,30 @@ The following call returns information about the logged-in customer. Provide the
}
```

The following example checks whether the email address `[email protected]` is available to create a customer account.

**Request**

```text
{
isEmailAvailable(email: "[email protected]") {
is_email_available
}
}
```

**Response**

```json
{
"data": {
"isEmailAvailable": {
"is_email_available": true
}
}
}
```

## Mutations
Use mutations to update server-side data, such as adding a new customer or modifying attributes for an existing customer.

Expand Down