Error while Fetching Orders

Error while Fetching Orders

Gokul2
Visitor
1 0 0
We use fetch order API to fetch pending orders into our OMS/WMS system. We also use GraphQL queries to fetch the location to which these orders are allocated to as shown in the attached calls.

But the GraphQL query in some cases does not return the results for all the requested orders and usually ends up leaving out one of the orders as illustrated in the below two calls:

Raised a request for orders 4077743210646 OR 4077744291990 OR 4077744685206 but was only given results for orders 4077743210646 AND 4077744291990, leaving out 4077744685206.

http_request

{"query":"query{\n orders(first: 4,\n query: \"id:4077743210646 OR 4077744291990 OR 4077744685206\"){\n edges{\n node{\n fulfillmentOrders(first: 5){\n edges{\n node{\n id\n lineItems(first: 20){\n edges{\n node{\n lineItem{\n id\n }\n id\n }\n }\n }assignedLocation{\n location{\n id\n }\n }\n }\n }\n }\n }\n }\n }\n}","variables":null}

http_uri

https://libasdelhi.myshopify.com/admin/api/2020-04/graphql.json

response

{"data":{"orders":{"edges":[{"node":{"fulfillmentOrders":{"edges":[{"node":{"id":"gid:\/\/shopify\/FulfillmentOrder\/5021497950358","lineItems":{"edges":[{"node":{"lineItem":{"id":"gid:\/\/shopify\/LineItem\/10407885340822"},"id":"gid:\/\/shopify\/FulfillmentOrderLineItem\/10517678686358"}}]},"assignedLocation":{"location":{"id":"gid:\/\/shopify\/Location\/40961015948"}}}}]}}},{"node":{"fulfillmentOrders":{"edges":[{"node":{"id":"gid:\/\/shopify\/FulfillmentOrder\/5021499097238","lineItems":{"edges":[{"node":{"lineItem":{"id":"gid:\/\/shopify\/LineItem\/10407887405206"},"id":"gid:\/\/shopify\/FulfillmentOrderLineItem\/10517680750742"}}]},"assignedLocation":{"location":{"id":"gid:\/\/shopify\/Location\/62278697110"}}}}]}}}]}},"extensions":{"cost":{"requestedQueryCost":914,"actualQueryCost":22,"throttleStatus":{"maximumAvailable":2000.0,"currentlyAvailable":1978,"restoreRate":100.0}}}}

Please clarify as to why this is happening and help us resolve the same.

Reply 1 (1)

awwdam
Shopify Staff
249 42 38

Hey @Gokul2,

I have a few questions for you here:

1. Are you able to locate the order not returned in your API request from within the admin directly, or request the order  and data using a different API request? 
2. Have you tried using a more recent API version, since 2020-04 is technically no longer support and deprecated? 
3. Does the API return data using the same request, but isolating the the id that didn't return details in your example?  EG:

{
  orders(first: 4, query: "id:4077744685206") {
    edges {
      node {
        id
        fulfillmentOrders(first: 5) {
          edges {
            node {
              id
              lineItems(first: 20) {
                edges {
                  node {
                    lineItem {
                      id
                    }
                    id
                  }
                }
              }
              assignedLocation {
                location {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}


Also, if you are able to replicate this request and unexpected behaviour again, could you  log the value returned in the x-request-id response header and share it along here - I'd be happy to search for logs and pass back any insights or next steps - Cheers!

awwdam | API Support @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog