How to access Graphql order query fulfillments field as an array

Solved
tonypmuk
Tourist
5 0 1

This simplified graphql order query has a field called fulfillments. 

query($id: ID!)
{ order(id: $id) {
    id
    name
    fulfillments
  }
}

The fulfillments field returns an array and I was hoping that this field would give me a simple list of fulfillments for the order, but I cannot see how to access the array field.

ie.  the result for the field is "fulfillments"=>[{"__typename"=>"Fulfillment"}]

but I cannot see how to access fulfillment without it being a connection. 

 

ps

It is possible to get at fulfillments as a connection on fulfillmentOrder so it is not a major issue, I just wonder if I am being silly or I am missing some knowledge on how to construct the query to return the content of the fulfillments array field?

 

0 Likes
_JB
Shopify Staff
Shopify Staff
821 97 178

This is an accepted solution.

Hey @tonypmuk,

You'll need to specify fields on the fulfillment object in order to get data in the response. For example:

{
  orders(first: 10) {
    edges {
      node {
        fulfillments {
          id
          totalQuantity
        }
      }
    }
  }
}

The response will only contain data for orders which are fulfilled, otherwise you'll still get an empty array.

JB | Developer 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

0 Likes
tonypmuk
Tourist
5 0 1

Spot on! 

it hadn't occurred to me that field names could be presented in as an array in that way.  Should have thought to have tried it.

Thank you for your help, 

 

0 Likes