reactioncommerce/example-storefront

Unnecessary request for anonymous cart and account cart

willopez opened this issue · 3 comments

Type: minor

Describe the bug
On a clean installation, request for the anonymous cart and account cart will be executed even though, they are explicitly directed not to by the skip param. This is a known issue with Apollo Client, apollographql/react-apollo#3492. Revisit this after Apollo Client v3 is released and hopefully fixed.

To Reproduce
Steps to reproduce the behavior:

  1. Start with fresh installation
  2. Load product grid page
  3. Observe the following query being executed:
anonymousCartByCartIdQuery
with params: 
"cartId":null,
"cartToken":null

Expected behavior
This query should not execute on first executed until a user clicks on the "add to cart" button. See, https://github.com/reactioncommerce/example-storefront/blob/trunk/hooks/cart/useCart.js#L50 for details.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome
  • Version 83

As react-apollo is deprecated, here are some more recent related issues on apollo-client which is the library we're currerently experiencing that issue with:

apollographql/apollo-client#6572
apollographql/apollo-client#6507
apollographql/apollo-client#6190

v3.0.0 stable was released 4 hours ago, will check if that maybe contains a fix already.

@janus-reith sounds good and thank you for checking. And looks like this PR might be related to this issue: apollographql/apollo-client#6589

@willopez Yes I was thinking the same thing when I noticed it. Looking at the code, that itself probably won't solve it as the logic regarding onCompleted is happening after the query ran or was skipped accordingly, but at least it looks like they're currently working at that topic somehow.