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

Migrating Customer endpoint to new directories as per Magedoc3973 #5124

Merged
merged 16 commits into from
Aug 27, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
33 changes: 30 additions & 3 deletions _data/toc/graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,18 @@ pages:
- label: currency query
url: /graphql/queries/directory-currency.html

- label: customer query
url: /graphql/queries/customer.html

- label: customerOrders query
url: /graphql/queries/customer-orders.html

- label: customerPaymentTokens query
url: /graphql/queries/customer-payment-tokens.html

- label: isEmailAvailable query
url: /graphql/queries/is-email-available.html

- label: storeConfig query
url: /graphql/queries/store-config.html

Expand All @@ -82,20 +88,41 @@ pages:
- label: applyStoreCreditToCart mutation
url: /graphql/mutations/apply-store-credit.html

- label: changeCustomerPassword mutation
url: /graphql/mutations/change-customer-password.html

- label: createCustomerAddress mutation
url: /graphql/mutations/create-customer-address.html

- label: createCustomer mutation
url: /graphql/mutations/create-customer.html

- label: deleteCustomerAddress mutation
url: /graphql/mutations/delete-customer-address.html

- label: deletePaymentToken mutation
url: /graphql/mutations/delete-payment-token.html

- label: generateCustomerToken mutation
url: /graphql/mutations/generate-customer-token.html

- label: removeStoreCreditFromCart mutation
url: /graphql/mutations/remove-store-credit.html

- label: revokeCustomerToken mutation
url: /graphql/mutations/revoke-customer-token.html

- label: updateCustomerAddress mutation
url: /graphql/mutations/update-customer-address.html

- label: updateCustomer mutation
url: /graphql/mutations/update-customer.html

- label: Reference
children:
- label: CustomAttributeMetadata endpoint
url: /graphql/reference/custom-attribute-metadata.html

- label: Customer endpoint
url: /graphql/reference/customer.html

- label: Payflow Link getPayflowLinkToken query
url: /graphql/reference/paypal-get-payflow-link-token.html

Expand Down
13 changes: 13 additions & 0 deletions _includes/graphql/create-customer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Attribute | Data Type | Description
--- | --- | ---
`dob` | String | The customer’s date of birth
`email` | String | The customer’s email address. Required to create a customer
`firstname` | String | The customer’s first name. Required to create a customer
`gender` | Int | The customer's gender (Male - 1, Female - 2)
`is_subscribed` | Boolean | The customer's new password
`lastname` | String | The customer’s last name. Required to create a customer
`middlename` | String | The customer’s middle name
`password` | String | The customer's password. Required to create a customer
`prefix` | String | An honorific, such as Dr., Mr., or Mrs.
`suffix` | String | A value such as Sr., Jr., or III
`taxvat` | String | The customer’s Tax/VAT number (for corporate customers)
2 changes: 1 addition & 1 deletion guides/v2.3/graphql/get-customer-authorization-token.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ You can now use this token in the Authorization request header field for any que

![GraphiQL Authorization Bearer]({{ page.baseurl }}/graphql/images/graphql-authorization.png)

If necessary, you also can [revoke the customer's token]({{ page.baseurl }}/graphql/reference/customer.html#revoke-a-customer-token).
If necessary, you also can [revoke the customer's token]({{ page.baseurl }}/graphql/mutations/revoke-customer-token.html).
58 changes: 58 additions & 0 deletions guides/v2.3/graphql/mutations/change-customer-password.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
group: graphql
title: changeCustomerPassword mutation
---

Use the `changeCustomerPassword` mutation to change the password for the logged-in customer.

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).

## Syntax

`mutation: {changeCustomerPassword(currentPassword: String!newPassword: String!) {Customer}}`

## Example usage

The following call updates the customer's password.

**Request**

```graphql
mutation {
changeCustomerPassword(
currentPassword: "[email protected]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
currentPassword: "[email protected]",
currentPassword: "[email protected]"

newPassword: "[email protected]"
) {
id
email
}
}
```

**Response**

```json
{
"data": {
"changeCustomerPassword": {
"id": 1,
"email": "[email protected]"
}
}
}
```

## Input attributes

The `changeCustomerPassword` object requires the following inputs:

Attribute | Data Type | Description
--- | --- | ---
`currentPassword` | String | The customer's current password
`newPassword` | String | The customer's new password

## Related topics

* [customer query]({{page.baseurl}}/graphql/queries/customer.html)
* [createCustomer mutation]({{page.baseurl}}/graphql/mutations/create-customer.html)
* [updateCustomer mutation]({{page.baseurl}}/graphql/mutations/update-customer.html)
138 changes: 138 additions & 0 deletions guides/v2.3/graphql/mutations/create-customer-address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
group: graphql
title: createCustomerAddress mutation
---

Use the `createCustomerAddress` mutation to create the customer's address.

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).

## Syntax

`mutation: {createCustomerAddress(input: CustomerAddressInput!) {CustomerAddress}}`

## Example usage

The following call creates an address for the specified customer.

**Request**

```graphql
mutation {
createCustomerAddress(input: {
region: {
region: "Arizona"
region_id: 4
region_code: "AZ"
}
country_id: US
street: ["123 Main Street"]
telephone: "7777777777"
postcode: "77777"
city: "Phoenix"
firstname: "Bob"
lastname: "Loblaw"
default_shipping: true
default_billing: false
}) {
id
customer_id
region {
region
region_id
region_code
}
country_id
street
telephone
postcode
city
default_shipping
default_billing
}
}
```

**Response**

```json
{
"data": {
"createCustomerAddress": {
"id": 4,
"customer_id": 5,
"region": {
"region": "Arizona",
"region_id": 4,
"region_code": "AZ"
},
"country_id": "US",
"street": [
"123 Main Street"
],
"telephone": "7777777777",
"postcode": "77777",
"city": "Phoenix",
"default_shipping": true,
"default_billing": false
}
}
}
```

## Input attributes

Attribute | Data Type | Description
--- | --- | ---
`id` | Int | The ID assigned to the address object
`CustomerAddressInput` | [CustomerAddress](#customerAddressInput) | An array containing the customer’s shipping and billing addresses

### Customer address input attributes {#customerAddressInput}

Attribute | Data Type | Description
--- | --- | ---
`city` | String | The city or town
`company` | String | The customer's company
`country_id` | CountryCodeEnum | The customer's country
`custom_attributes` | [CustomerAddressAttributeInput](#customerAddressAttributeInput) | Address custom attributes
`customer_id` | Int | The customer ID
`default_billing` | Boolean | Indicates whether the address is the default billing address
`default_shipping` | Boolean | Indicates whether the address is the default shipping address
`fax` | String | The fax number
`firstname` | String | The first name of the person associated with the shipping/billing address
`lastname` | String | The family name of the person associated with the shipping/billing address
`middlename` | String | The middle name of the person associated with the shipping/billing address
`postcode` | String | The customer's ZIP or postal code
`prefix` | String | An honorific, such as Dr., Mr., or Mrs.
`region` | [CustomerAddressRegionInput](#customerAddressRegionInput) | An object that defines the customer's state or province
`street` | [String] | An array of strings that define the street number and name
`suffix` | String | A value such as Sr., Jr., or III
`telephone` | String | The telephone number
`vat_id` | String | The customer's Tax/VAT number (for corporate customers)

### Customer address attributes {#customerAddressAttributeInput}

The `CustomerAddressAttributeInput` object can contain the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`attribute_code` | String | Attribute code
`value` | String | Attribute value

### Customer address region input attributes {#customerAddressRegionInput}

The `customerAddressRegionInput` object can contain the following attributes:

Attribute | Data Type | Description
--- | --- | ---
`region_code` | String | The address region code
`region` | String | The state or province name
`region_id` | Int | Uniquely identifies the region

## Related topics

* [customer query]({{page.baseurl}}/graphql/queries/customer.html)
* [createCustomer mutation]({{page.baseurl}}/graphql/mutations/create-customer.html)
* [updateCustomer mutation]({{page.baseurl}}/graphql/mutations/update-customer.html)
* [updateCustomerAddress mutation]({{page.baseurl}}/graphql/mutations/update-customer-address.html)
* [deleteCustomerAddress mutation]({{page.baseurl}}/graphql/mutations/delete-customer-address.html)
72 changes: 72 additions & 0 deletions guides/v2.3/graphql/mutations/create-customer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
group: graphql
title: createCustomer mutation
---

Use the `createCustomer` mutation to create a new customer.

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).

## Syntax

`mutation: {createCustomer(input: CustomerInput!) {CustomerOutput}}`

## Example usage

The following call creates a new customer.

**Request**

```graphql
mutation {
createCustomer(
input: {
firstname: "Bob"
lastname: "Loblaw"
email: "[email protected]"
password: "b0bl0bl@w"
is_subscribed: true
}
) {
customer {
id
firstname
lastname
email
is_subscribed
}
}
}
```

**Response**

```json
{
"data": {
"createCustomer": {
"customer": {
"id": 5,
"firstname": "Bob",
"lastname": "Loblaw",
"email": "[email protected]",
"is_subscribed": true
}
}
}
}
```

## Input attributes

The following table lists the attributes you can use as input for the `createCustomer` mutation. The [Customer attributes]({{page.baseurl}}/graphql/queries/customer.html#customerAttributes) table lists the attributes Magento returns.

{% include graphql/create-customer.md %}

## Related topics

* [customer query]({{page.baseurl}}/graphql/queries/customer.html)
* [updateCustomer mutation]({{page.baseurl}}/graphql/mutations/update-customer.html)
* [createCustomerAddress mutation]({{page.baseurl}}/graphql/mutations/create-customer-address.html)
* [updateCustomerAddress mutation]({{page.baseurl}}/graphql/mutations/update-customer-address.html)
* [deleteCustomerAddress mutation]({{page.baseurl}}/graphql/mutations/delete-customer-address.html)
Loading