Can we pipe the GraphQL results from one mutation to another?

Tom13
Shopify Partner
6 0 0

I am following the tutorial to edit an existing order with Admin API. In total, 4 requests are required to accomplish the task of adding a free variant to an existing order programmatically.

  1. orderEditBegin mutation
  2. addVariantToOrder mutation
  3. orderEditAddLineItemDiscount mutation (100% discount)
  4. orderEditCommit mutation

Understandably, the result of the prior mutation is used in the next mutation in the sequence stated above. 

For example: the id of the addedLineItems returned from the addVariantToOrder is used in the orderEditAddLineItemDiscount mutation to apply a discount to the newly added line item.

However, I wanted to know if there is any way to lessen the number of requests in order to fulfill the same task. I am concern about the delays on the frontend for the user due the many "roundtrips" involved between the client and the server. I have tried searching online and it seems that there is no way to pipe result from one mutation to another in GraphQL.

Any advice is appreciated!

0 Likes