Order Update in bulk GraphQL

Chakori
New Member
1 0 0

Trying to update order by using GraphQL by using 

HttpRequest graphQLRequest = new HttpRequest();
        graphQLRequest.setEndpoint('endpoint');
        graphQLRequest.setMethod('POST');
        graphQLRequest.setHeader('content-type', 'application/json');
        graphQLRequest.setHeader('X-Shopify-Access-Token', 'password');
        http httpSource =  new Http();   
        graphQLRequest.setBody('{"query" : "mutation { orderUpdate(input: {id: \\"gid:\\/\\/shopify\\/Order\\/37454834238791\\", note: \\"test\\"}) { order{id note}}}"}');
        HttpResponse graphQLResponse = new HttpResponse();
        graphQLResponse = httpSource.send(graphQLRequest);
        graphQLResults = graphQLResponse.getBody();
 
The above code is working for single order update, but when tried to bulkify the code as follows:
HttpRequest graphQLRequest = new HttpRequest();
        graphQLRequest.setEndpoint('endpoint');
        graphQLRequest.setMethod('POST');
        graphQLRequest.setHeader('content-type', 'application/json');
        graphQLRequest.setHeader('X-Shopify-Access-Token', 'password');
        http httpSource =  new Http();   
        graphQLRequest.setBody('{"query" : "mutation { orderUpdate(input: [{id: \\"gid:\\/\\/shopify\\/Order\\/37454834238791\\", note: \\"test\\"}, {id: \\"gid:\\/\\/shopify\\/Order\\/37454834238234\\", note: \\"test123\\"}]) { order{id note}}}"}');
        HttpResponse graphQLResponse = new HttpResponse();
        graphQLResponse = httpSource.send(graphQLRequest);
        graphQLResults = graphQLResponse.getBody();
 
It is not working.
 
Can someone please suggest me how to do bulk update on orders by using GraphQL?
0 Likes