Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmptyCart and RemoveItemsFromCart mutation don't work #454

Closed
believelody opened this issue Mar 12, 2021 · 2 comments
Closed

EmptyCart and RemoveItemsFromCart mutation don't work #454

believelody opened this issue Mar 12, 2021 · 2 comments

Comments

@believelody
Copy link
Contributor

Describe the bug
Hi guys, I have a big weird problem with emptyCart and removeItemsFromCart mutations. I'm using react as wordpress theme (so I'm working directly in wordpress folder) with create-react-wptheme. I copied -> pasted an older standalone react project with WP as backend inside of this react wordpress theme. It's basically the same thing ! THEN...
The problem is:

  • I add products into cart, everything work fine;
  • I update item quantity, it's okay;
  • If I have at least 2 products and I delete one of them, it works, item is correctly deleted, cart is updated;
  • Now, if I have only ONE item in cart or want to delete all items...then nothing happen;

I 'm using the @apollo/client library so when I use a mutation with useMutation, I also call refetch method from useQuery to refetch cart after some update. This "refetch" works when I add an item or update a existing item in cart like I said above. I don't understand at all why for removing last item or deleting all, refetch gives me back a non updated cart.

Expected behavior
These two mutations work fine in graphiql in admin dashboard (I mean when I query cart after calling one of these two, my cart is updated), so I expect the same in my app.

Screenshots

This is how I proceed. I call "refetch" in "onCompleted" callback provided by useMutation
image

As you can see in this screenshot, removeItemsFromCart mutation seems to work but refetch doesn't bring me back the correct updated cart. It's very strange.
image

This last screenshot is my apollo configuration
image

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version 18

Plugin Versions

  • WooGraphQL Version: 0.5.1
  • WPGraphQL Version: 1.1.5
  • WordPress Version: 5.5.3
  • WooCommerce Version: 5.0.0

Additional context
The WEIRDEST thing is...Everything work perfectly in my standalone react project (the one I copied to use directly in wordpress folder).

@kidunot89
Copy link
Member

@believelody See this

@believelody
Copy link
Contributor Author

Ooh my bad 😱 !!! Thank you so much 😄
Everything work correctly now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants