From 1f8f3d9c46a23e907f9209d260f4639dde482320 Mon Sep 17 00:00:00 2001 From: Andy Terranova <13182778+supernova-at@users.noreply.github.com> Date: Wed, 19 Feb 2020 16:27:17 -0600 Subject: [PATCH] [bugfix]: Do not cache create customer or sign in mutation data (#2176) * Do not cache create customer or sign in mutation data * Ensure shipping and guest email is not persisted in cache Co-authored-by: Tommy Wiebell --- .../peregrine/lib/talons/Checkout/useAddressForm.js | 7 +++++-- .../lib/talons/CreateAccount/useCreateAccount.js | 12 +++++++++--- packages/peregrine/lib/talons/SignIn/useSignIn.js | 4 +++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/packages/peregrine/lib/talons/Checkout/useAddressForm.js b/packages/peregrine/lib/talons/Checkout/useAddressForm.js index 775f463a3d..eec3e1725f 100644 --- a/packages/peregrine/lib/talons/Checkout/useAddressForm.js +++ b/packages/peregrine/lib/talons/Checkout/useAddressForm.js @@ -33,9 +33,12 @@ export const useAddressForm = props => { const [{ isSignedIn }] = useUserContext(); - const [setGuestEmail] = useMutation(setGuestEmailMutation); + const [setGuestEmail] = useMutation(setGuestEmailMutation, { + fetchPolicy: 'no-cache' + }); const [setShippingAddressOnCart] = useMutation( - setShippingAddressOnCartMutation + setShippingAddressOnCartMutation, + { fetchPolicy: 'no-cache' } ); const values = useMemo( () => diff --git a/packages/peregrine/lib/talons/CreateAccount/useCreateAccount.js b/packages/peregrine/lib/talons/CreateAccount/useCreateAccount.js index fc1d0a34d8..f5d5863971 100644 --- a/packages/peregrine/lib/talons/CreateAccount/useCreateAccount.js +++ b/packages/peregrine/lib/talons/CreateAccount/useCreateAccount.js @@ -39,12 +39,18 @@ export const useCreateAccount = props => { { getUserDetails, setToken } ] = useUserContext(); + const [fetchCartId] = useMutation(createCartMutation); + + // For create account and sign in mutations, we don't want to cache any + // personally identifiable information (PII). So we set fetchPolicy to 'no-cache'. const [createAccount, { error: createAccountError }] = useMutation( - createAccountQuery + createAccountQuery, + { fetchPolicy: 'no-cache' } ); + const [signIn, { error: signInError }] = useMutation(signInMutation, { + fetchPolicy: 'no-cache' + }); - const [fetchCartId] = useMutation(createCartMutation); - const [signIn, { error: signInError }] = useMutation(signInMutation); const fetchUserDetails = useAwaitQuery(customerQuery); const fetchCartDetails = useAwaitQuery(getCartDetailsQuery); diff --git a/packages/peregrine/lib/talons/SignIn/useSignIn.js b/packages/peregrine/lib/talons/SignIn/useSignIn.js index d81f66e7fe..7ca942a29e 100644 --- a/packages/peregrine/lib/talons/SignIn/useSignIn.js +++ b/packages/peregrine/lib/talons/SignIn/useSignIn.js @@ -23,7 +23,9 @@ export const useSignIn = props => { { getUserDetails, setToken } ] = useUserContext(); - const [signIn, { error: signInError }] = useMutation(signInMutation); + const [signIn, { error: signInError }] = useMutation(signInMutation, { + fetchPolicy: 'no-cache' + }); const [fetchCartId] = useMutation(createCartMutation); const fetchUserDetails = useAwaitQuery(customerQuery); const fetchCartDetails = useAwaitQuery(getCartDetailsQuery);