All things Shopify and commerce
Hi!
I have a question about Shopify Graphql,If I make two graphql requests at the same time. One is `cartLinesAdd` and the other is `cartLinesRemove`,Then I found that the products I added were not in the final shopping cart.
For example, the original shopping cart has two products, and `cartLinesAdd`and `cartLinesRemove` are called at the same time. Normally, there should be two products in the cart, but in the end, only one product is left in the shopping cart.
I don’t know if the problem is caused by concurrency. Is there any solution?
Hi,
This is Richard at PageFly - Shopify Advanced Page Builder app.
You're likely encountering concurrency issues with your Shopify GraphQL mutations. Here's a breakdown of the problem and potential solutions:
Understanding the Issue
Solutions
Sequential Execution:
Implement Logic: Introduce logic to ensure sequential execution of mutations. For example:
Optimistic Updates (with Caution):
Optimistically Update Client-Side: After a successful cartLinesAdd mutation, update your local cart state (in your frontend application) immediately.
Handle Rollbacks: If the server-side mutation fails, roll back the optimistic update on the client-side.
Caution: Optimistic updates can lead to inconsistencies if not implemented carefully. Thoroughly test and handle potential race conditions.
Shopify API Limitations:
Hoping my solution helps you solve your problem.
Best regards,
Richard | PageFly
Please let me know if it works by giving it a Like or marking it as a solution!
➜ Optimize your Shopify store with PageFly Page Builder (Free plan available)
All features are available from Free plan. Live Chat Support is available 24/7.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025