diff --git a/hooks/availablePaymentMethods/useAvailablePaymentMethods.js b/hooks/availablePaymentMethods/useAvailablePaymentMethods.js index 29a9ab490f..490ad55925 100644 --- a/hooks/availablePaymentMethods/useAvailablePaymentMethods.js +++ b/hooks/availablePaymentMethods/useAvailablePaymentMethods.js @@ -15,7 +15,7 @@ export default function useAvailablePaymentMethods() { const [viewer, isLoadingViewer] = useViewer(); const { loading, data, refetch } = useQuery(availablePaymentMethodsQuery, { - skip: !shop || isLoadingViewer, + skip: !shop._id || isLoadingViewer, variables: { shopId: shop && shop._id } diff --git a/hooks/cart/useCart.js b/hooks/cart/useCart.js index 2f9eefbb7c..cc579ccbbc 100644 --- a/hooks/cart/useCart.js +++ b/hooks/cart/useCart.js @@ -38,6 +38,8 @@ export default function useCart() { const shouldSkipAnonymousCartByCartIdQuery = Boolean(accountId || isLoadingViewer || !cartStore.anonymousCartId || !cartStore.anonymousCartToken); const { loading: isLoading, data: cartData, fetchMore, refetch: refetchCart } = useQuery(accountCartByAccountIdQuery, { + // TODO: Revisit this extra request on load, skip is not respected and is as known issue in Apollo Client + // https://github.com/apollographql/react-apollo/issues/3492 skip: shouldSkipAccountCartByAccountIdQuery, variables: { accountId, @@ -47,6 +49,8 @@ export default function useCart() { }); const { data: cartDataAnonymous, refetch: refetchCartAnonymous } = useQuery(anonymousCartByCartIdQuery, { + // TODO: Revisit this extra request on load, skip is not respected and is as known issue in Apollo Client + // https://github.com/apollographql/react-apollo/issues/3492 skip: shouldSkipAnonymousCartByCartIdQuery, variables: { cartId: cartStore.anonymousCartId, diff --git a/pages/api/account/token.js b/pages/api/account/token.js index c499044d09..59e2d21779 100644 --- a/pages/api/account/token.js +++ b/pages/api/account/token.js @@ -17,7 +17,8 @@ const token = async (req, res) => { } } - return res.status(401).send(JSON.stringify({ error: "No authorization data present" })); + // Anonymous user + return res.status(200).send(JSON.stringify({ anonymous: true })); }; export default passportMiddleware(token);