Solved

FulfillmentOrders always returning empty for orders in GraphQL API

jeggah
Tourist
5 1 7

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

Accepted Solution (1)
jeggah
Tourist
5 1 7

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.

View solution in original post

Replies 8 (8)

jeggah
Tourist
5 1 7

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?

jeggah
Tourist
5 1 7

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.

DaveRS
Tourist
10 0 6

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.

tonypmuk
Shopify Partner
8 0 5

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.

 

 

DaveRS
Tourist
10 0 6

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?

Nate_Daily
Shopify Partner
4 0 6

For those that didn't give up on Graphql, like so many of us have desperately wanted to do. This is the correct answer.

 

Shopify should add what permissions you need for each object in the Graphql documentation.

jameslobsenz
Tourist
5 0 0

Thank you! Wow that was annoying. Another documentation fail.

remy727
Shopify Partner
40 2 22
You will need read_merchant_managed_fulfillment_orders scope.

FulfillmentOrder Requires Any of read_assigned_fulfillment_orders, read_merchant_managed_fulfillment_orders, read_third_party_fulfillment_orders, read_marketplace_fulfillment_orders access scopes.

I tried with read_assigned_fulfillment_orders but I got empty results with no error.
But I got the result with read_merchant_managed_fulfillment_orders.


Looking for a Shopify App developer? Please visit: https://github.com/remy727