Skip to content

Commit

Permalink
[bugfix]: Do not cache create customer or sign in mutation data (#2176)
Browse files Browse the repository at this point in the history
* 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 <twiebell@adobe.com>
  • Loading branch information
2 people authored and dpatil-magento committed Feb 19, 2020
1 parent e31779e commit 1f8f3d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/peregrine/lib/talons/Checkout/useAddressForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
() =>
Expand Down
12 changes: 9 additions & 3 deletions packages/peregrine/lib/talons/CreateAccount/useCreateAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 3 additions & 1 deletion packages/peregrine/lib/talons/SignIn/useSignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1f8f3d9

Please sign in to comment.