FulfillmentOrders always returning empty for orders in GraphQL API

Solved
jeggah
Tourist
5 1 5

Hi,

I'm having trouble with the graphQL API (2020-10)

For this simple query I'm running to get FulfillmentOrders for an Order:

query order($id: ID!) {
  order(id: $id) {
    createdAt
    fulfillmentOrders(first: 10) {
      edges {
        node {
          assignedLocation {
            location {
              id
            }
          }
        }
      }
    }
  }
}

 

This Query works perfectly on the Shopify GraphiQL App.

But when running on my Custom app, fulfillmentOrders always returns empty edges!

The app has the appropriate access, and can return all the other different properties of an Order.

Is there an issue going on with the API?

Thanks

0 Likes
jeggah
Tourist
5 1 5

Update. I have found that the assignedLocations will only be populated if our default Location is used in that order. So if 2 locations were used, it will only return 1.

If a location was used that wasn't the default location, it will return blank.

Any idea why this is?

0 Likes
jeggah
Tourist
5 1 5

This is an accepted solution.

Update. Gave up and went with the REST solution at https://shopify.dev/docs/admin-api/rest/reference/shipping-and-fulfillment/fulfillmentorder

There is definitely a bug in the GraphQL API that doesn't give you permission to see locations that aren't default. And it's even more annoying that it works perfectly in Shopify GraphiQL App. So you're convinced it is a problem in your code. Shame I spent a whole day on this.

0 Likes
DaveRS
Tourist
9 0 4

I've been fighting with this issue recently, thinking it was a problem in the GraphQL client library I was using (dotnet) or in the JSON deserialization.  I had even given up for a several weeks and moved on to other dev items.  I came back to it tonight and found this thread, and it gave me an idea.  The GraphQL app has full permissions, so I started looking at the private app API token I was using, and after a bit of experimentation, discovered that once I granted the "Merchant-managed fulfillment orders" Read Access, the fulfillmentOrders collection was being returned properly and deserialized properly in my app code.

DaveRS_0-1618731514125.png

Before:

DaveRS_2-1618731684607.png

 

After:

DaveRS_1-1618731637096.png

Hope this helps anyone else fighting this problem.  The docs could probably be clearer about which token permissions are needed for a given edge of the graph API.

0 Likes
tonypmuk
Tourist
5 0 1

I am glad I found this thread, because I was seeing the same issue.  The fulfillmentOrders appeared once I had requested the merchant_managed_fulfillment_orders scope. 

 

I would still suggest this is a bug though.  Surely adding the fulfillmentOrders field to the Order query should result in a permission error which I believe

is the case if  assigned_fulfillment_orders scope is not requested.

 

 

0 Likes
DaveRS
Tourist
9 0 4

Agreed.  Throwing a security error here, rather than just not returning that segment of the graph, would have been significantly better and saved me tens of hours of chasing the wild goose of deserialization problems.  Any way we can tag a Shopify staffer to call their attention to this thread?

0 Likes