From 214197906e9394bfc9b5fcfe68dc2fc4373ec2a1 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Date: Mon, 1 Jun 2020 15:52:31 -0500 Subject: [PATCH 1/5] Requesting price summary fragment in shipping info mutation. --- .../ShippingInformation/AddressForm/guestForm.gql.js | 3 +++ .../ShippingInformation/shippingInformation.gql.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js index d40877576b..34f64fce5c 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js @@ -2,6 +2,7 @@ import gql from 'graphql-tag'; import { ShippingInformationFragment } from '../shippingInformationFragments.gql'; import { ShippingMethodsCheckoutFragment } from '../../ShippingMethod/shippingMethodFragments.gql'; +import { PriceSummaryFragment } from '../../../CartPage/PriceSummary/priceSummaryFragments'; export const SET_GUEST_SHIPPING_MUTATION = gql` mutation SetGuestShipping( @@ -26,11 +27,13 @@ export const SET_GUEST_SHIPPING_MUTATION = gql` id ...ShippingInformationFragment ...ShippingMethodsCheckoutFragment + ...PriceSummaryFragment } } } ${ShippingInformationFragment} ${ShippingMethodsCheckoutFragment} + ${PriceSummaryFragment} `; export default { diff --git a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js index a31acab966..db43a8875c 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js @@ -2,6 +2,7 @@ import gql from 'graphql-tag'; import { ShippingInformationFragment } from './shippingInformationFragments.gql'; import { ShippingMethodsCheckoutFragment } from '../ShippingMethod/shippingMethodFragments.gql'; +import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFragments'; export const GET_SHIPPING_INFORMATION = gql` query GetShippingInformation($cartId: String!) { @@ -34,11 +35,13 @@ export const SET_CUSTOMER_ADDRESS_ON_CART = gql` id ...ShippingInformationFragment ...ShippingMethodsCheckoutFragment + ...PriceSummaryFragment } } } ${ShippingInformationFragment} ${ShippingMethodsCheckoutFragment} + ${PriceSummaryFragment} `; export default { From 0b6e45219e836fe6343eb03678e297a016dbc108 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Date: Tue, 2 Jun 2020 12:44:52 -0500 Subject: [PATCH 2/5] Fetching order summary on billing address change. --- .../CheckoutPage/PaymentInformation/creditCard.gql.js | 3 +++ .../CheckoutPage/PaymentInformation/paymentInformation.gql.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js index 274351f82d..21c085f627 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js @@ -1,4 +1,5 @@ import gql from 'graphql-tag'; +import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFragments'; // We disable linting for local fields because there is no way to add them to // the fetched schema. Additionally, since we don't want to make a network call @@ -115,9 +116,11 @@ export const SET_BILLING_ADDRESS = gql` postcode telephone } + ...PriceSummaryFragment } } } + ${PriceSummaryFragment} `; export const SET_CC_DETAILS_ON_CART = gql` diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js index 4c3afeeb64..b37c148df0 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js @@ -1,4 +1,5 @@ import gql from 'graphql-tag'; +import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFragments'; // We disable linting for local fields because there is no way to add them to // the fetched schema. @@ -80,9 +81,11 @@ export const SET_BILLING_ADDRESS = gql` postcode telephone } + ...PriceSummaryFragment } } } + ${PriceSummaryFragment} `; // Sets the provided payment method object on the cart. From a2b0cb415b66e4c26d4a38e4f09af84a81ea5e45 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Date: Wed, 3 Jun 2020 12:59:50 -0500 Subject: [PATCH 3/5] Fetching available payment methods on shipping and billing address change. --- .../PaymentInformation/creditCard.gql.js | 4 ++++ .../paymentInformation.gql.js | 17 +++++++++++++---- .../AddressForm/guestForm.gql.js | 3 +++ .../shippingInformation.gql.js | 3 +++ 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js index 21c085f627..e5f58106cb 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js @@ -1,5 +1,7 @@ import gql from 'graphql-tag'; + import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFragments'; +import { AvailablePaymentMethodsFragment } from './paymentInformation.gql'; // We disable linting for local fields because there is no way to add them to // the fetched schema. Additionally, since we don't want to make a network call @@ -117,10 +119,12 @@ export const SET_BILLING_ADDRESS = gql` telephone } ...PriceSummaryFragment + ...AvailablePaymentMethodsFragment } } } ${PriceSummaryFragment} + ${AvailablePaymentMethodsFragment} `; export const SET_CC_DETAILS_ON_CART = gql` diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js index 6d0f5c4dc5..18f7213ab8 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js @@ -4,15 +4,20 @@ import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFr // We disable linting for local fields because there is no way to add them to // the fetched schema. // https://github.com/apollographql/eslint-plugin-graphql/issues/99 +export const AvailablePaymentMethodsFragment = gql` + fragment AvailablePaymentMethodsFragment on Cart { + available_payment_methods { + code + title + } + } +`; + /* eslint-disable graphql/template-strings */ export const GET_PAYMENT_INFORMATION = gql` query getPaymentInformation($cartId: String!) { cart(cart_id: $cartId) @connection(key: "Cart") { id - available_payment_methods { - code - title - } selected_payment_method { code } @@ -30,8 +35,10 @@ export const GET_PAYMENT_INFORMATION = gql` } telephone } + ...AvailablePaymentMethodsFragment } } + ${AvailablePaymentMethodsFragment} `; /* eslint-disable graphql/required-fields */ @@ -92,10 +99,12 @@ export const SET_BILLING_ADDRESS = gql` telephone } ...PriceSummaryFragment + ...AvailablePaymentMethodsFragment } } } ${PriceSummaryFragment} + ${AvailablePaymentMethodsFragment} `; // Sets the provided payment method object on the cart. diff --git a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js index 34f64fce5c..7f9fa5a2f1 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/AddressForm/guestForm.gql.js @@ -3,6 +3,7 @@ import gql from 'graphql-tag'; import { ShippingInformationFragment } from '../shippingInformationFragments.gql'; import { ShippingMethodsCheckoutFragment } from '../../ShippingMethod/shippingMethodFragments.gql'; import { PriceSummaryFragment } from '../../../CartPage/PriceSummary/priceSummaryFragments'; +import { AvailablePaymentMethodsFragment } from '../../PaymentInformation/paymentInformation.gql'; export const SET_GUEST_SHIPPING_MUTATION = gql` mutation SetGuestShipping( @@ -28,12 +29,14 @@ export const SET_GUEST_SHIPPING_MUTATION = gql` ...ShippingInformationFragment ...ShippingMethodsCheckoutFragment ...PriceSummaryFragment + ...AvailablePaymentMethodsFragment } } } ${ShippingInformationFragment} ${ShippingMethodsCheckoutFragment} ${PriceSummaryFragment} + ${AvailablePaymentMethodsFragment} `; export default { diff --git a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js index db43a8875c..83805c7cb4 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/ShippingInformation/shippingInformation.gql.js @@ -3,6 +3,7 @@ import gql from 'graphql-tag'; import { ShippingInformationFragment } from './shippingInformationFragments.gql'; import { ShippingMethodsCheckoutFragment } from '../ShippingMethod/shippingMethodFragments.gql'; import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFragments'; +import { AvailablePaymentMethodsFragment } from '../PaymentInformation/paymentInformation.gql'; export const GET_SHIPPING_INFORMATION = gql` query GetShippingInformation($cartId: String!) { @@ -36,12 +37,14 @@ export const SET_CUSTOMER_ADDRESS_ON_CART = gql` ...ShippingInformationFragment ...ShippingMethodsCheckoutFragment ...PriceSummaryFragment + ...AvailablePaymentMethodsFragment } } } ${ShippingInformationFragment} ${ShippingMethodsCheckoutFragment} ${PriceSummaryFragment} + ${AvailablePaymentMethodsFragment} `; export default { From 553e31265e5e75da87749b7ffce31849c459539b Mon Sep 17 00:00:00 2001 From: Revanth Kumar Date: Wed, 3 Jun 2020 14:32:58 -0500 Subject: [PATCH 4/5] Added id in available payment methods fragment. --- .../CheckoutPage/PaymentInformation/paymentInformation.gql.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js index 18f7213ab8..4922378f5d 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js @@ -6,6 +6,7 @@ import { PriceSummaryFragment } from '../../CartPage/PriceSummary/priceSummaryFr // https://github.com/apollographql/eslint-plugin-graphql/issues/99 export const AvailablePaymentMethodsFragment = gql` fragment AvailablePaymentMethodsFragment on Cart { + id available_payment_methods { code title From 06608bff1cbdf6ac405673efc877af8d56813f59 Mon Sep 17 00:00:00 2001 From: Revanth Kumar Date: Wed, 3 Jun 2020 16:36:36 -0500 Subject: [PATCH 5/5] Minor. --- .../CheckoutPage/PaymentInformation/creditCard.gql.js | 4 +++- .../CheckoutPage/PaymentInformation/paymentInformation.gql.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js index e5f58106cb..541524d8b6 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/creditCard.gql.js @@ -7,6 +7,7 @@ import { AvailablePaymentMethodsFragment } from './paymentInformation.gql'; // the fetched schema. Additionally, since we don't want to make a network call // for "id" we disable "required-fields" // https://github.com/apollographql/eslint-plugin-graphql/issues/99 + /* eslint-disable graphql/template-strings */ /* eslint-disable graphql/required-fields */ export const GET_IS_BILLING_ADDRESS_SAME = gql` @@ -24,8 +25,9 @@ export const GET_PAYMENT_NONCE = gql` } } `; + +/* eslint-enable graphql/required-fields */ /* eslint-enable graphql/template-strings */ -/* eslint-disable graphql/required-fields */ export const GET_BILLING_ADDRESS = gql` query getBillingAddress($cartId: String!) { diff --git a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js index 4922378f5d..1e03cbed38 100644 --- a/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js +++ b/packages/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentInformation.gql.js @@ -51,6 +51,7 @@ export const GET_PAYMENT_NONCE = gql` } `; +/* eslint-enable graphql/required-fields */ /* eslint-enable graphql/template-strings */ export const SET_BILLING_ADDRESS = gql`