Skip to content

Commit 93f6e5e

Browse files
committed
Added schema concept for working with cart addresses and shipping methods
1 parent 8fd89cf commit 93f6e5e

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,82 @@
11
# Copyright © Magento, Inc. All rights reserved.
22
# See COPYING.txt for license details.
33

4+
type Query {
5+
getAvailableShippingMethodsOnCart(input: AvailableShippingMethodsOnCartInput): AvailableShippingMethodsOnCartOutput @doc(description:"Returns available shipping methods for cart by address/address_id")
6+
}
7+
48
type Mutation {
59
createEmptyCart: String @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Cart\\CreateEmptyCart") @doc(description:"Creates empty shopping cart for guest or logged in user")
610
applyCouponToCart(input: ApplyCouponToCartInput): ApplyCouponToCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Coupon\\ApplyCouponToCart")
711
removeCouponFromCart(input: RemoveCouponFromCartInput): RemoveCouponFromCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Coupon\\RemoveCouponFromCart")
12+
setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput): SetShippingAddressesOnCartOutput
13+
setBillingAddressOnCart(input: SetBillingAddressOnCartInput): SetBillingAddressOnCartOutput
14+
setShippingMethodsOnCart(input: SetShippingMethodsOnCartInput): SetShippingMethodsOnCartOutput
15+
}
16+
17+
input SetShippingAddressesOnCartInput {
18+
cart_id: String!
19+
customer_address_id: Int # Can be provided in one-page checkout and is required for multi-shipping checkout
20+
address: CartAddressInput
21+
cart_items: [CartItemQuantityInput!]
22+
}
23+
24+
input CartItemQuantityInput {
25+
cart_item_id: Int!
26+
quantity: Float!
27+
}
28+
29+
input SetBillingAddressOnCartInput {
30+
cart_id: String!
31+
customer_address_id: Int
32+
address: CartAddressInput
33+
# TODO: consider adding "Same as shipping" option
34+
}
35+
36+
input CartAddressInput {
37+
firstname: String!
38+
lastname: String!
39+
company: String
40+
street: [String!]!
41+
city: String!
42+
region: String
43+
postcode: String
44+
country_code: String!
45+
telephone: String!
46+
save_in_address_book: Boolean!
47+
}
48+
49+
input SetShippingMethodsOnCartInput {
50+
shipping_methods: [ShippingMethodForAddressInput!]!
51+
}
52+
53+
input ShippingMethodForAddressInput {
54+
cart_address_id: String!
55+
shipping_method_code: String!
56+
}
57+
58+
type SetBillingAddressOnCartOutput {
59+
cart: Cart!
60+
}
61+
62+
type SetShippingAddressesOnCartOutput {
63+
cart: Cart!
64+
}
65+
66+
type SetShippingMethodsOnCartOutput {
67+
cart: Cart!
68+
}
69+
70+
# If no address is provided, the system get address assigned to a quote
71+
# If there's no address at all - the system returns all shipping methods
72+
type AvailableShippingMethodsOnCartInput {
73+
cart_id: String!
74+
customer_address_id: Int
75+
address: CartAddressInput
76+
}
77+
78+
type AvailableShippingMethodsOnCartOutput {
79+
available_shipping_methods: [CheckoutShippingMethod]
880
}
981

1082
input ApplyCouponToCartInput {
@@ -18,12 +90,56 @@ type ApplyCouponToCartOutput {
1890

1991
type Cart {
2092
applied_coupon: AppliedCoupon
93+
addresses: [CartAddress]!
2194
}
2295

2396
type CartAddress {
97+
firstname: String!
98+
lastname: String!
99+
company: String
100+
street: [String!]!
101+
city: String!
102+
region: CartAddressRegion
103+
postcode: String
104+
country: CartAddressCountry!
105+
telephone: String!
106+
address_type: AdressTypeEnum!
107+
selected_shipping_method: CheckoutShippingMethod
108+
available_shipping_methods: [CheckoutShippingMethod]!
109+
items_weight: Float
110+
customer_notes: String
111+
cart_items: [CartItemQuantity]
24112
applied_coupon: AppliedCoupon
25113
}
26114

115+
type CartItemQuantity {
116+
cart_item_id: String!
117+
quantity: Float!
118+
}
119+
120+
type CartAddressRegion {
121+
code: String
122+
label: String
123+
}
124+
125+
type CartAddressCountry {
126+
code: String
127+
label: String
128+
}
129+
130+
type CheckoutShippingMethod {
131+
code: String
132+
label: String
133+
free_shipping: Boolean!
134+
error_message: String
135+
# TODO: Add more complex structure for shipping rates
136+
}
137+
138+
enum AdressTypeEnum {
139+
SHIPPING
140+
BILLING
141+
}
142+
27143
type AppliedCoupon {
28144
code: String!
29145
}

0 commit comments

Comments
 (0)