Multiple Graphql mutations from one form

Highlighted
Excursionist
12 1 3

I'm building an admin app to use internally at my company and I followed the "Build a Shopify app with Node and React" tutorial from Shopify. Everything is working great but now I'm at the mutation step and my use case is different from the tutorial and I'm stuck. Here's what I'm trying to do:

 

  • I built a resource picker that searches for products.
  • I can select as many products as necessary. These products are then displayed in a resource list, along with cancel and submit buttons.
  • Upon clicking submit, I need to add a tag of "no_discount" to each products, and then update all variants for each product to be discounted 30% by changing the product price and adding a compare at price that is equal to the current product price.

 

Screen Shot 2019-09-16 at 10.12.17 AM.png

 

I don't see how to dynamically set the mutation string depending on the number of products selected and run all of this inside the Apollo Mutation component. I'm fairly new to React/Apollo/Graphql and I'm struggling to find details for how to accomplish this. If anyone can point me in the right direction it would be appreciated!

0 Likes