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

Commit a62478d

Browse files
authored
Merge pull request #7436 from magento/kh_graphql-customer-orders
GraphQL: Add support for order details in My Orders
2 parents 16b7d16 + 8f17062 commit a62478d

8 files changed

+764
-14
lines changed

src/_includes/graphql/customer-address-output.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### CustomerAddress attributes {#customerAddressOutput}
1+
### Address attributes (CustomerAddress) {#customerAddressOutput}
22

33
The values assigned to attributes such as `firstname` and `lastname` in this object may be different from those defined in the `Customer` object.
44

@@ -29,7 +29,7 @@ Attribute | Data Type | Description
2929
`telephone` | String | The telephone number
3030
`vat_id` | String | The customer's Tax/VAT number (for corporate customers)
3131

32-
### CustomerAddressAttribute attributes {#customerAddressAttributeOutput}
32+
#### CustomerAddressAttribute attributes {#customerAddressAttributeOutput}
3333

3434
The `CustomerAddressAttribute` output data type has been deprecated because the contents are not applicable for GraphQL. It can contain the following attributes:
3535

@@ -38,7 +38,7 @@ Attribute | Data Type | Description
3838
`attribute_code` | String | Attribute code
3939
`value` | String | Attribute value
4040

41-
### CustomerAddressRegion attributes {#customerAddressRegionOutput}
41+
#### CustomerAddressRegion attributes {#customerAddressRegionOutput}
4242

4343
The `customerAddressRegion` output returns the following attributes:
4444

src/_includes/graphql/customer-orders-output.md

Lines changed: 341 additions & 0 deletions
Large diffs are not rendered by default.

src/_includes/graphql/customer-output-24.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
{% if page.url contains 'graphql/queries/customer.html' %}
2+
{% assign customeraddress_text = '[CustomerAddress](#customerAddressOutput)' %}
3+
{% assign customeroutput_text = '[CustomerOrders](#customerOrders)' %}
4+
{% assign crossref_text = '. See [`orders` input attributes](#orders) for details' %}
5+
{% else %}
6+
{% assign customeraddress_text = 'CustomerAddress' %}
7+
{% assign customeroutput_text = '[CustomerOrders]' %}
8+
{% assign crossref_text = '' %}
9+
{% endif %}
10+
111
Attribute | Data Type | Description
212
--- | --- | ---
3-
`addresses` | [CustomerAddress](#customerAddressOutput) | An array containing the customer's shipping and billing addresses
13+
`addresses` | {{ customeraddress_text }} | An array containing the customer's shipping and billing addresses
414
`created_at` | String | Timestamp indicating when the account was created
515
`date_of_birth` | String | The customer's date of birth
616
`default_billing` | String | The ID assigned to the billing address
@@ -14,9 +24,8 @@ Attribute | Data Type | Description
1424
`is_subscribed` | Boolean | Indicates whether the customer is subscribed to the company's newsletter
1525
`lastname` | String | The customer's family name
1626
`middlename` |String | The customer's middle name
27+
`orders(<FilterCriteria>)` | {{ customeroutput_text }} | A list of the customer's placed orders{{ crossref_text }}
1728
`prefix` | String | An honorific, such as Dr., Mr., or Mrs.
1829
`suffix` | String | A value such as Sr., Jr., or III
1930
`taxvat` | String | The customer's Tax/VAT number (for corporate customers)
2031
`wishlist` | Wishlist! | Contains the contents of the customer's wish lists
21-
22-
{% include graphql/customer-address-output-24.md %}

src/guides/v2.4/graphql/mutations/change-customer-password.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
group: graphql
3+
title: changeCustomerPassword mutation
4+
---
5+
6+
Use the `changeCustomerPassword` mutation to change the password for the logged-in customer.
7+
8+
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).
9+
10+
## Syntax
11+
12+
`mutation: {changeCustomerPassword(currentPassword: String! newPassword: String!) {Customer}}`
13+
14+
## Example usage
15+
16+
The following call updates the customer's password.
17+
18+
**Request:**
19+
20+
```graphql
21+
mutation {
22+
changeCustomerPassword(
23+
currentPassword: "[email protected]"
24+
newPassword: "[email protected]"
25+
) {
26+
id
27+
email
28+
}
29+
}
30+
```
31+
32+
**Response:**
33+
34+
```json
35+
{
36+
"data": {
37+
"changeCustomerPassword": {
38+
"id": 1,
39+
"email": "[email protected]"
40+
}
41+
}
42+
}
43+
```
44+
45+
## Input attributes
46+
47+
The `changeCustomerPassword` mutation requires the following inputs:
48+
49+
Attribute | Data Type | Description
50+
--- | --- | ---
51+
`currentPassword` | String | The customer's current password
52+
`newPassword` | String | The customer's new password
53+
54+
## Output attributes
55+
56+
The `changeCustomerPassword` mutation returns the `customer` object.
57+
58+
The following table lists the top-level attributes of the `customer` object. See the [`customer` query]({{page.baseurl}}/graphql/queries/customer.html) for complete details about this object.
59+
60+
{% include graphql/customer-output-24.md %}
61+
62+
## Errors
63+
64+
Error | Description
65+
--- | ---
66+
`The current customer isn't authorized.` | The customer's token does not exist in the `oauth_token` table.
67+
`Invalid login or password.` | The password specified in the `currentPassword` argument is not valid.
68+
`Specify the "currentPassword" value.` | The password specified in the `currentPassword` argument is empty.
69+
`Specify the "newPassword" value.` | The password specified in the `newPassword` argument is empty.
70+
`The account is locked.` | The customer's password cannot be changed because the account is locked.
71+
72+
## Related topics
73+
74+
* [customer query]({{page.baseurl}}/graphql/queries/customer.html)
75+
* [createCustomer mutation]({{page.baseurl}}/graphql/mutations/create-customer.html)
76+
* [updateCustomer mutation]({{page.baseurl}}/graphql/mutations/update-customer.html)

src/guides/v2.4/graphql/mutations/create-customer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ The following table lists the attributes you can use as input for the `createCus
6565

6666
The `createCustomer` mutation returns the `CustomerOutput` object.
6767

68+
The following table lists the top-level attributes of the `customer` object. See the [`customer` query]({{page.baseurl}}/graphql/queries/customer.html) for complete details about this object.
69+
6870
{% include graphql/customer-output-24.md %}
6971

7072
## Errors

src/guides/v2.4/graphql/mutations/update-customer.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ The following table lists the attributes you can use as input for the `updateCus
5858

5959
The `updateCustomer` mutation returns the `CustomerOutput` object.
6060

61+
The following table lists the top-level attributes of the `customer` object. See the [`customer` query]({{page.baseurl}}/graphql/queries/customer.html) for complete details about this object.
62+
6163
{% include graphql/customer-output-24.md %}
6264

6365
## Related topics

src/guides/v2.4/graphql/queries/customer-orders.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
group: graphql
3+
title: customerOrders query
4+
---
5+
{:.bs-callout-warning}
6+
The `customerOrders` query has been deprecated. Specify the `orders` object in the [`customer`]({{page.baseurl}}/graphql/queries/customer.html) query instead.
7+
8+
The Sales module performs a wide variety of functions, including order, invoice, and shipment management. However, most of these functions are performed on the backend, and the customer does not have access to this information. By returning a list of customer orders, the `customerOrders` query allows a customer to retrieve their order histories.
9+
10+
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).
11+
12+
## Syntax
13+
14+
`{customerOrders {CustomerOrders}}`
15+
16+
## Example usage
17+
18+
The following query returns the order history of the logged in customer.
19+
20+
**Request:**
21+
22+
```graphql
23+
{
24+
customerOrders {
25+
items {
26+
order_number
27+
id
28+
created_at
29+
grand_total
30+
status
31+
}
32+
}
33+
}
34+
```
35+
36+
**Response:**
37+
38+
```json
39+
{
40+
"data": {
41+
"customerOrders": {
42+
"items": [
43+
{
44+
"order_number": "000000001",
45+
"id": 1,
46+
"created_at": "2019-02-21 00:24:34",
47+
"grand_total": 36.39,
48+
"status": "processing"
49+
},
50+
{
51+
"order_number": "000000002",
52+
"id": 2,
53+
"created_at": "2019-02-21 00:24:35",
54+
"grand_total": 39.64,
55+
"status": "closed"
56+
}
57+
]
58+
}
59+
}
60+
}
61+
```
62+
63+
## Output attributes
64+
65+
The `CustomerOrders` object contains the `items` attribute.
66+
67+
Attribute | Data type | Description
68+
--- | --- | ---
69+
`items` | [`[CustomerOrder]`](#customerOrderAttributes) | An array of customer orders
70+
71+
### Customer order items attributes {#customerOrderAttributes}
72+
73+
The `CustomerOrder` object defines details about each order the customer has placed.
74+
75+
Attribute | Data type | Description
76+
--- | --- | ---
77+
`created_at` | String | A timestamp indicating when the order was placed
78+
`grand_total` | Float | The total of the order
79+
`id` | Int | The ID assigned to the customer's order
80+
`increment_id` | String | Deprecated. Use `order_number` instead. An ID that indicates the sequence of the order in the customer's order history
81+
`order_number` | String! | The order number assigned to the order
82+
`status` | String | The status of the order, such as `open`, `processing`, or `closed`
83+
84+
## Errors
85+
86+
Error | Description
87+
--- | ---
88+
`The current customer isn't authorized.` | The current customer is not currently logged in, or the customer's token does not exist in the `oauth_token` table.

0 commit comments

Comments
 (0)