Solved

GraphQL Query Fails When Run as JSON

gcb0323
Visitor
3 1 0

This query runs fine in the GraphiQL editor but when I run it as a JSON request I get a 400 response. 

 

The json provided is not formatted correctly

 

 

If I remove the pagination request "after: ..." it runs as expected.

 

Is there something about my formatting of the "after" request that isn't JSON friendly?

 

 

{
  "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 } } }}"
}

 

 

Accepted Solution (1)

gcb0323
Visitor
3 1 0

This is an accepted solution.

Solved my own question. I needed to escape the quotes within my query.

 

{
  "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 } } }}"
}

View solution in original post

Reply 1 (1)

gcb0323
Visitor
3 1 0

This is an accepted solution.

Solved my own question. I needed to escape the quotes within my query.

 

{
  "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 } } }}"
}