Order line items relation to fulfillment

We have a need to map order line items to fulfillment (bunch of other information is also used, but not relevant to this), but unable to do so using GraphQL orders bulk query. Order.fulfillments is a list inside Order object, so its connection fulfillmentLineItems can’t be used as we get error: “Queries that contain a connection field within a list field are not currently supported.”. (lot of information was removed to increase visibility)

mutation {
  bulkOperationRunQuery(
    query: """
      {
          orders(query: "id:XXXXXX")
          {
                  edges {
                      node {
                          fulfillments {
                              fulfillmentLineItems {
                                  edges {
                                      node {
                                          id
                                      }
                                  }
                              }
                          }
                      }
                  }
              }
      }
    """
  ) {
    bulkOperation {
      id
    }
    userErrors {
      field
      message
    }
  }
}

Other way I could think of is using Order.fulfillmentOrders, then reaching to fulfillments and eventually fulfillmentLineItems. But that goes beyond 2 levels of connections nesting as we get error: “Bulk queries cannot contain connections with a nesting depth greater than 2.”.

mutation {
  bulkOperationRunQuery(
    query: """
      {
          orders(query: "id:XXX")
          {
                  edges {
                      node {
                          fulfillmentOrders {
                              edges {
                                  node {
                                      id
                                      fulfillments {
                                          edges {
                                              node {
                                                  id
                                                  fulfillmentLineItems {
                                                      edges {
                                                          node {
                                                              id
                                                          }
                                                      }
                                                  }
                                              }
                                          }
                                      }
                                  }
                          }
                          }
                      }
                  }
              }
      }
    """
  ) {
    bulkOperation {
      id
    }
    userErrors {
      field
      message
    }
  }
}

Desired outcome would have data that would let me do something like:

[

order_line_item_id_1 => fulfillfment_id_1,

order_line_item_id_2 => fulfillfment_id_1,

order_line_item_id_3 => fulfillfment_id_2,

order_line_item_id_4 => fulfillfment_id_3,

etc…

]

Am I missing something obvious, or trying something that is not possible?

Hey @VladV4 ,

Thanks for sharing some of the limitations you’re running in to here with bulk operations.

Currently you would have to split these up in to multiple operations as the nesting depth limitation.

I’ll be sure to pass this feedback on to our product teams.

  • Kyle G.
1 Like