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 all 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 `[email protected]` and password `b1b2b3l@w+`.
Expand Down
242 changes: 8 additions & 234 deletions src/guides/v2.3/graphql/tutorials/checkout/checkout-billing-address.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,16 @@ contributor_link: https://www.atwix.com/
{:.bs-callout-tip}
You must always set the billing address to place an order.

Use the [setBillingAddressOnCart]({{ page.baseurl }}/graphql/mutations/set-billing-address.html) mutation to set a billing address. You can set the billing address in the following ways:
Use the [setBillingAddressOnCart]({{ page.baseurl }}/graphql/mutations/set-billing-address.html) mutation to set a billing address.

* Add a new billing address
* Add a new billing address and set it as the shipping addresses
* Use an address from the logged-in customer's address book
## Add a billing address to the cart

## Add a new billing address
Similar to the shipping address, add a billing address to the 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 street address is also different, so we can see that different addresses are being created.

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

{:.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.

```graphql
mutation {
setBillingAddressOnCart(
Expand All @@ -42,236 +37,15 @@ mutation {
firstname: "John"
lastname: "Doe"
company: "Company Name"
street: ["320 N Crescent Dr", "Beverly Hills"]
street: ["64 Strawberry Dr", "Beverly Hills"]
city: "Los Angeles"
region: "CA"
region_id: 12
postcode: "90210"
country_code: "US"
telephone: "123-456-0000"
save_in_address_book: false
}
}
}
) {
cart {
billing_address {
firstname
lastname
company
street
city
region{
code
label
}
postcode
telephone
country {
code
label
}
}
}
}
}
```

**Response:**

```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"
}
}
}
}
}
}
```

## Add a new address for billing and shipping

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

**Request:**

```text
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
}
same_as_shipping: true
}
}
) {
cart {
billing_address {
firstname
lastname
company
street
city
region{
code
label
}
postcode
telephone
country {
code
label
}
}
shipping_addresses {
firstname
lastname
company
street
city
postcode
telephone
country {
code
label
}
}
}
}
}
```

**Response:**

```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"
}
},
"shipping_addresses": [
{
"firstname": "John",
"lastname": "Doe",
"company": "Company Name",
"street": [
"320 N Crescent Dr",
"Beverly Hills"
],
"city": "Los Angeles",
"postcode": "90210",
"telephone": "123-456-0000",
"country": {
"code": "US",
"label": "US"
}
}
]
}
}
}
}
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

```

## Use an existing customer address

First, query the customer to return the list of address IDs.

**Request:**

```text
query {
customer {
addresses {
id
default_billing
default_shipping
}
}
}
```

**Response:**

```text
"data": {
"customer": {
"addresses": [
{
"id": 2,
"default_billing": true,
"default_shipping": true
save_in_address_book: true
}
]
}
}
}
```

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

**Request:**

```text
mutation {
setBillingAddressOnCart(
input: {
cart_id: "{ CART_ID }"
billing_address: {
customer_address_id: { CUSTOMER_ADDRESS_ID }
}
}
) {
Expand Down Expand Up @@ -310,7 +84,7 @@ mutation {
"lastname": "Doe",
"company": "Company Name",
"street": [
"320 N Crescent Dr",
"64 Strawberry Dr",
"Beverly Hills"
],
"city": "Los Angeles",
Expand Down
Loading