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

Reworked GraphQL tutorial #8046

Merged
merged 30 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6432b4d
Updates
Oct 12, 2020
4efe4fa
Reworked graphql tutorial
Oct 14, 2020
bc2ebdb
Dusting off the lint
Oct 14, 2020
f7d331c
That wasn't me.
Oct 14, 2020
255de77
Merge branch 'master' into db_graphql_tutorial
dobooth Oct 14, 2020
10da0df
Merge branch 'db_graphql_tutorial' of github.com:magento/devdocs into…
Oct 14, 2020
fb5fe58
Update src/guides/v2.3/graphql/tutorials/checkout/checkout-add-produc…
dobooth Oct 23, 2020
3feb86e
Apply suggestions from code review
dobooth Oct 23, 2020
e34abca
Removed query per review
dobooth Oct 23, 2020
3660040
Fixup per review
dobooth Oct 23, 2020
1db53d7
Code block fixup
dobooth Oct 23, 2020
a58057e
Review fixups
dobooth Oct 23, 2020
7ff0ee1
Reversion per review
dobooth Oct 23, 2020
9abc94e
Added link
dobooth Oct 23, 2020
5c6f0b3
Merge branch 'master' into db_graphql_tutorial
dobooth Oct 23, 2020
d8e40c0
Fix codeblock
dobooth Oct 23, 2020
8b64330
Merge branch 'master' into db_graphql_tutorial
keharper Oct 27, 2020
68ab141
Update src/guides/v2.3/graphql/tutorials/checkout/checkout-coupon.md
dobooth Oct 28, 2020
02e4b62
Merge branch 'master' into db_graphql_tutorial
Oct 28, 2020
7f9f89e
Updates
Oct 29, 2020
a798196
Updated shipping address steps
Nov 2, 2020
0aa8fe1
Linty
Nov 2, 2020
d801e49
Updated steps
Nov 4, 2020
d72580b
trailing space
Nov 4, 2020
5a1a7f3
Merge branch 'master' into db_graphql_tutorial
dobooth Nov 4, 2020
359cf83
Small tweak to coupon instructions.
Nov 23, 2020
29fbd91
Merge branch 'master' into db_graphql_tutorial
dobooth Nov 23, 2020
ce62e94
Added shipping method steps.
Nov 23, 2020
8e6dbd0
Merge branch 'db_graphql_tutorial' of github.com:magento/devdocs into…
Nov 23, 2020
810255a
Update checkout-shipping-address.md
keharper Nov 23, 2020
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
18 changes: 9 additions & 9 deletions src/guides/v2.3/graphql/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ landing-page: GraphQL Developer's Guide

As of Magento 2.3.4, GraphQL provides the following features:

* Support for all product types, payment methods, and shipping methods
* Achieved <.5 sec average response times with 500 concurrent requests
* Redesigned a feature rich layered navigation
- Support for all product types, payment methods, and shipping methods
- Achieved <.5 sec average response times with 500 concurrent requests
- Redesigned a feature rich layered navigation

## Where we're going

The `graphql-ce` Community Engineering repository has been archived. Development for Magento 2.3.5 will be limited to bug fixes.

For the 2.4.0 and 2.4.1 releases, Magento teams are working toward completing GraphQL coverage for Business to Consumer (B2C) uses cases, with emphasis on the following:

* Reorders
* Inventory Management store pickups
* Order history for logged in customers
* Replace product-specific mutations that add products to a cart with a single mutation that can handle all product types
* Gift wrapping and messages
* Saved payment methods
- Reorders
- Inventory Management store pickups
- Order history for logged in customers
- Replace product-specific mutations that add products to a cart with a single mutation that can handle all product types
- Gift wrapping and messages
- Saved payment methods

We also expect to begin adding coverage for B2B scenarios.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ If you add a product to the shopping cart as a registered customer, be sure to s

## Add a simple product into the shopping cart

`{ CART_ID }` is the unique shopping cart ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).
The following mutation adds a simple product into the shopping cart.

The following mutation adds a **simple product** into shopping cart.
Replace `{ CART_ID }` with the unique shopping cart ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).

In this example, we will add the Aim Analog Watch (SKU 24-MG04) from the default Luma catalog to the cart. The SKU identifies the product to be added.

**Request:**

Expand All @@ -46,7 +48,7 @@ mutation {
{
data: {
quantity: 1
sku: "simple-product"
sku: "24-MG04"
}
}
]
Expand Down Expand Up @@ -75,9 +77,9 @@ mutation {
"cart": {
"items": [
{
"id": "508",
"id": "5",
"product": {
"sku": "simple-product",
"sku": "24-MG04",
"stock_status": "IN_STOCK"
},
"quantity": 1
Expand All @@ -91,7 +93,8 @@ mutation {

## Add a virtual product into the shopping cart

The following mutation adds a **virtual product** into shopping cart.
The following mutation adds a virtual product into the shopping cart.
In this example, we add the Beginner's Yoga video downloadable product (SKU 240-LV04).

**Request:**

Expand All @@ -104,7 +107,7 @@ mutation {
{
data: {
quantity: 1
sku: "virtual-product"
sku: "240-LV04"
}
}
]
Expand Down Expand Up @@ -133,9 +136,17 @@ mutation {
"cart": {
"items": [
{
"id": "509",
"id": "5",
"product": {
"sku": "virtual-product",
"sku": "24-MG04",
"stock_status": "IN_STOCK"
},
"quantity": 1
},
{
"id": "6",
"product": {
"sku": "240-LV04",
"stock_status": "IN_STOCK"
},
"quantity": 1
Expand All @@ -147,6 +158,8 @@ mutation {
}
```

The response lists all items currently in the cart, including the just-added video download.

## Verify this step {#verify-step}

1. Sign in as a customer to the website using the email `john.doe@example.com` and password `b1b2b3l@w+`.
Expand Down
157 changes: 77 additions & 80 deletions src/guides/v2.3/graphql/tutorials/checkout/checkout-billing-address.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,42 @@ Use the [setBillingAddressOnCart]({{ page.baseurl }}/graphql/mutations/set-billi

## Add a new billing address

The following mutation adds a new billing address. `{ CART_ID }` is the unique shopping cart ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).
Similar to the previous step, we will add a billing address to the customer. `{ CART_ID }` is the unique shopping cart ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html). In this example, the `default_billing` parameter is set to `true`. The street address is also different, so we can see that different addresses are being created.
Copy link
Contributor

Choose a reason for hiding this comment

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

Get rid of everything but adding a billing address to the cart, so the procedure is the same for guests and customers.

The shipping and billing addresses are now different. That's OK, but be sure to mention that.


**Request:**
Send the customer's authorization token in the `Authorization` parameter of the header. See [Authorization tokens]({{page.baseurl}}/graphql/authorization-tokens.html) for more information.

{:.bs-callout .bs-callout-info}
For logged-in customers, send the customer's authorization token in the `Authorization` parameter of the header. See [Authorization tokens]({{page.baseurl}}/graphql/authorization-tokens.html) for more information.
**Request:**

```graphql
mutation {
setBillingAddressOnCart(
input: {
cart_id: "{ CART_ID }"
billing_address: {
address: {
firstname: "John"
lastname: "Doe"
company: "Company Name"
street: ["320 N Crescent Dr", "Beverly Hills"]
city: "Los Angeles"
region: "CA"
postcode: "90210"
country_code: "US"
telephone: "123-456-0000"
save_in_address_book: false
}
}
createCustomerAddress(input: {
region: {
region: "Arizona"
region_code: "AZ"
region_id: 4
}
) {
cart {
billing_address {
firstname
lastname
company
street
city
region{
code
label
}
postcode
telephone
country {
code
label
}
}
country_code: US
street: ["123 Stone Ave."]
telephone: "7777777777"
postcode: "77777"
city: "Phoenix"
firstname: "Bob"
lastname: "Loblaw"
default_shipping: false
default_billing: true
}) {
id
region {
region
region_code
}
country_code
street
telephone
postcode
city
default_shipping
default_billing
}
}
```
Expand All @@ -81,41 +70,37 @@ mutation {
```json
{
"data": {
"setBillingAddressOnCart": {
"cart": {
"billing_address": {
"firstname": "John",
"lastname": "Doe",
"company": "Company Name",
"street": [
"320 N Crescent Dr",
"Beverly Hills"
],
"city": "Los Angeles",
"region": {
"code": "CA",
"label": "California"
},
"postcode": "90210",
"telephone": "123-456-0000",
"country": {
"code": "US",
"label": "US"
}
}
}
"createCustomerAddress": {
"id": 3,
"region": {
"region": "Arizona",
"region_code": "AZ"
},
"country_code": "US",
"street": [
"123 Stone Ave."
],
"telephone": "7777777777",
"postcode": "77777",
"city": "Phoenix",
"default_shipping": false,
"default_billing": true
}
}
}
```

## Add a new address for billing and shipping
## Same address for billing and shipping

So far, we have created separate billing and shipping addresses and added them to the customer record.

The following mutation includes the `same_as_shipping` attribute, which allows the same address to be used for billing and shipping.
A common scenario is using the same address for both billing and shipping. A common pattern offers the ability to use the same address for both.

The following mutation includes the `same_as_shipping` attribute, which allows the same address to be used for billing and shipping on the cart.

**Request:**

```text
```graphql
mutation {
setBillingAddressOnCart(
input: {
Expand Down Expand Up @@ -224,13 +209,16 @@ mutation {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add these back. They're the closing marks for the data and top-level` objects. Also I think the lack of blank line afterward is causing the display problems in GH.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

```

We can confirm that the same address is specified for both addresses.

## Use an existing customer address

If you wish to change one of the addresses to use existing addresses, that is as follows.
First, query the customer to return the list of address IDs.

**Request:**

```text
```graphql
query {
customer {
addresses {
Expand All @@ -244,14 +232,20 @@ query {

**Response:**

```text
```json
{
"data": {
"customer": {
"addresses": [
{
"id": 2,
"default_billing": true,
"default_billing": false,
"default_shipping": true
},
{
"id": 3,
"default_billing": true,
"default_shipping": false
}
]
}
Expand All @@ -263,9 +257,11 @@ Set `{ CUSTOMER_ADDRESS_ID }` to an `id` returned in the query.

`{ CART_ID }` is the unique shopping cart ID from [Step 2. Create empty cart]({{ page.baseurl }}/graphql/tutorials/checkout/checkout-add-product-to-cart.html).

Using the results from above, we can set the `{ CUSTOMER_ADDRESS_ID}` to `3` to use the default billing address.

**Request:**

```text
```graphql
mutation {
setBillingAddressOnCart(
input: {
Expand Down Expand Up @@ -306,20 +302,19 @@ mutation {
"setBillingAddressOnCart": {
"cart": {
"billing_address": {
"firstname": "John",
"lastname": "Doe",
"company": "Company Name",
"firstname": "Bob",
"lastname": "Loblaw",
"company": null,
"street": [
"320 N Crescent Dr",
"Beverly Hills"
"123 Stone Ave."
],
"city": "Los Angeles",
"city": "Phoenix",
"region": {
"code": "CA",
"label": "California"
"code": "AZ",
"label": "Arizona"
},
"postcode": "90210",
"telephone": "123-456-0000",
"postcode": "77777",
"telephone": "7777777777",
"country": {
"code": "US",
"label": "US"
Expand All @@ -331,6 +326,8 @@ mutation {
}
```

The value of the `street` attribute ("123 Stone Ave.") is the default billing address we created at the beginning of this page.

## Verify this step {#verify-step}

1. Sign in as a customer to the website using the email `john.doe@example.com` and password `b1b2b3l@w+`.
Expand Down
Loading