From 11b3a4f55e90d41cb8efa81672fda5ab3c32df4b Mon Sep 17 00:00:00 2001
From: Valerii Naida <vnayda@adobe.com>
Date: Thu, 21 Feb 2019 11:16:45 -0600
Subject: [PATCH] GraphQL-292: Cleanup quote GraphQL scheme

---
 .../etc/schema.graphqls                       |  2 +-
 .../Magento/QuoteGraphQl/etc/schema.graphqls  | 93 ++++++++-----------
 2 files changed, 40 insertions(+), 55 deletions(-)

diff --git a/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls b/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls
index df95632c4b60..d4780c5c0867 100644
--- a/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/ConfigurableProductGraphQl/etc/schema.graphqls
@@ -49,7 +49,7 @@ type AddConfigurableProductsToCartOutput {
 }
 
 input ConfigurableProductCartItemInput {
-    data: CartItemDetailsInput!
+    data: CartItemInput!
     variant_sku: String!
     customizable_options:[CustomizableOptionInput!]
 }
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index f2806f6dd9f0..985b88b18d5c 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -7,15 +7,48 @@ type Query {
 
 type Mutation {
     createEmptyCart: String @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CreateEmptyCart") @doc(description:"Creates an empty shopping cart for a guest or logged in user")
-    applyCouponToCart(input: ApplyCouponToCartInput): ApplyCouponToCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Coupon\\ApplyCouponToCart")
-    removeCouponFromCart(input: RemoveCouponFromCartInput): RemoveCouponFromCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\Coupon\\RemoveCouponFromCart")
-    setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput): SetShippingAddressesOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetShippingAddressesOnCart")
+    addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
+    addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
     applyCouponToCart(input: ApplyCouponToCartInput): ApplyCouponToCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ApplyCouponToCart")
     removeCouponFromCart(input: RemoveCouponFromCartInput): RemoveCouponFromCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\RemoveCouponFromCart")
+    setShippingAddressesOnCart(input: SetShippingAddressesOnCartInput): SetShippingAddressesOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetShippingAddressesOnCart")
     setBillingAddressOnCart(input: SetBillingAddressOnCartInput): SetBillingAddressOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetBillingAddressOnCart")
     setShippingMethodsOnCart(input: SetShippingMethodsOnCartInput): SetShippingMethodsOnCartOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetShippingMethodsOnCart")
-    addSimpleProductsToCart(input: AddSimpleProductsToCartInput): AddSimpleProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
-    addVirtualProductsToCart(input: AddVirtualProductsToCartInput): AddVirtualProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
+}
+
+input AddSimpleProductsToCartInput {
+    cart_id: String!
+    cartItems: [SimpleProductCartItemInput!]!
+}
+
+input SimpleProductCartItemInput {
+    data: CartItemInput!
+    customizable_options:[CustomizableOptionInput!]
+}
+
+input AddVirtualProductsToCartInput {
+    cart_id: String!
+    cartItems: [VirtualProductCartItemInput!]!
+}
+
+input VirtualProductCartItemInput {
+    data: CartItemInput!
+    customizable_options:[CustomizableOptionInput!]
+}
+
+input CartItemInput {
+    sku: String!
+    qty: Float!
+}
+
+input CustomizableOptionInput {
+    id: Int!
+    value: String!
+}
+
+input ApplyCouponToCartInput {
+    cart_id: String!
+    coupon_code: String!
 }
 
 input SetShippingAddressesOnCartInput {
@@ -24,7 +57,7 @@ input SetShippingAddressesOnCartInput {
 }
 
 input ShippingAddressInput {
-    customer_address_id: Int # Can be provided in one-page checkout and is required for multi-shipping checkout
+    customer_address_id: Int # If provided then will be used address from address book
     address: CartAddressInput
     cart_items: [CartItemQuantityInput!]
 }
@@ -81,19 +114,6 @@ type SetShippingMethodsOnCartOutput {
     cart: Cart!
 }
 
-# If no address is provided, the system get address assigned to a quote
-# If there's no address at all - the system returns all shipping methods
-input AvailableShippingMethodsOnCartInput {
-    cart_id: String!
-    customer_address_id: Int
-    address: CartAddressInput
-}
-
-input ApplyCouponToCartInput {
-    cart_id: String!
-    coupon_code: String!
-}
-
 type ApplyCouponToCartOutput {
     cart: Cart!
 }
@@ -172,31 +192,6 @@ type RemoveCouponFromCartOutput {
     cart: Cart
 }
 
-input AddSimpleProductsToCartInput {
-    cart_id: String!
-    cartItems: [SimpleProductCartItemInput!]!
-}
-
-input AddVirtualProductsToCartInput {
-    cart_id: String!
-    cartItems: [VirtualProductCartItemInput!]!
-}
-
-input SimpleProductCartItemInput {
-    data: CartItemInput!
-    customizable_options:[CustomizableOptionInput!]
-}
-
-input VirtualProductCartItemInput {
-    data: CartItemInput!
-    customizable_options:[CustomizableOptionInput!]
-}
-
-input CustomizableOptionInput {
-    id: Int!
-    value: String!
-}
-
 type AddSimpleProductsToCartOutput {
     cart: Cart!
 }
@@ -213,11 +208,6 @@ type VirtualCartItem implements CartItemInterface @doc(description: "Virtual Car
     customizable_options: [SelectedCustomizableOption] @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\CustomizableOptions")
 }
 
-input CartItemInput {
-    sku: String!
-    qty: Float!
-}
-
 interface CartItemInterface @typeResolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\CartItemTypeResolver") {
     id: String!
     qty: Float!
@@ -246,8 +236,3 @@ type CartItemSelectedOptionValuePrice {
     units: String!
     type: PriceTypeEnum!
 }
-
-input CartItemDetailsInput {
-    sku: String!
-    qty: Float!
-}