GraphQL Query Fails When Run as JSON

Viewed 11

My query runs fine in a GraphiQL editor but fails when I run it as a JSON request. (400 The json provided is not formatted correctly)

Specifically it seems to be something to do with how I've phrased the "after:..." element. If I remove this the JSON request runs as expected.

{
  "query": "query{ orders(first: 3, after: "eyJsYXN0X2lkIjo0MzU5OTgzMjY3ODkzLCJsYXN0X3ZhbHVlIjoiMjAyMi0wNS0yMyAxMDozNzoyMy4wMDAwMDAifQ==") { edges { cursor node { id name legacyResourceId email createdAt processedAt totalPriceSet { shopMoney { amount currencyCode } } totalDiscountsSet { shopMoney { amount currencyCode } } totalRefundedSet { shopMoney { amount currencyCode } } subtotalLineItemsQuantity test } } }}"
}
1 Answers

Looks like the issue was that I was not escaping the quotes within my query.

Funny, the way Stack Overflow formatted my code was the tip off I needed.

{
  "query": "query{ orders(first: 3, after: \"eyJsYXN0X2lkIjo0MzU5OTgzMjY3ODkzLCJsYXN0X3ZhbHVlIjoiMjAyMi0wNS0yMyAxMDozNzoyMy4wMDAwMDAifQ\") { edges { cursor node { id name legacyResourceId email createdAt processedAt totalPriceSet { shopMoney { amount currencyCode } } totalDiscountsSet { shopMoney { amount currencyCode } } totalRefundedSet { shopMoney { amount currencyCode } } subtotalLineItemsQuantity test } } }}"
}
Related