Solved

Queries that contain a connection field within a list field are not currently supported

AW1234
Shopify Partner
44 7 12

Hi

I have the error Queries that contain a connection field within a list field are not currently supported with this bulk query

mutation {
        bulkOperationRunQuery(
          query:"""
          {
           orders(query:"created_at:>='${date.toISOString().split('.')[0]}Z' AND fulfillment_status:partial"){
            edges{
              node{
                id
                name
                fulfillments {
                  fulfillmentLineItems{
                    edges{
                      node{
                        lineItem{
                          sku
                        }
                        quantity
                      }
                    }
                  }
                  trackingInfo {
                    number
                  }
                }
......

I have done some research and found that I couldn't use "fulfillments" field in a bulk operation but I need this field so is there a known work around for this pls? I couldn't find anything by myself and I don't know shopify's graphql api enough, going through pagination would take hours instead of 5 min.

Thanks in advance to anyone that can help me.

Accepted Solution (1)

AW1234
Shopify Partner
44 7 12

This is an accepted solution.

Hi, I think I found a solution, if it can help someone else

mutation {
        bulkOperationRunQuery(
          query:"""
          {
           orders(reverse:true, first:1, query:"fulfillment_status:partial"){
            edges{
              node{
                id, name,
                fulfillmentOrders {
                  edges { 
                    node {
                      id,
                      lineItems {
                        edges {
                          node {
                            id, remainingQuantity, totalQuantity, sku
                          }
                        }
                      }
                      fulfillments {
                        edges {
                          node {
                            id
                            trackingInfo {
                              number
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        """
      ) {
        bulkOperation {
          id
          status
        }
        userErrors {
          field
          message
        }
      }
    }

So I found out that totalQuantity in fulfillmentOrders.lineItems is total-refunded so I can just, in my code, make total-remaining to find the fulfilledQuantity.

example:
you have an article with 4 quantity base, you refund 1 and fulfill 1, you will have 3 totalQuantity, 2 remainingQuantity

you fulfill 1 again, you have 3 total, 1 remaining

you refund 1 again, you have 2 total, 0 remaining


The only problem here is that the fulfilledquantity will not be attached to a tracking number as I can't query for 

fulfillmentLineItems {
                              edges {
                                node {
                                  quantity,
                                  lineItem {
                                    sku
                                  }
                                }
                              }
                            }

 in fulfillments because, in a bulk query, you can't have more than 2 nested connections or else you get this error Bulk queries cannot contain connections with a nesting depth greater than 2

This is in version 2023-01 BTW

View solution in original post

Replies 3 (3)

AW1234
Shopify Partner
44 7 12

This is an accepted solution.

Hi, I think I found a solution, if it can help someone else

mutation {
        bulkOperationRunQuery(
          query:"""
          {
           orders(reverse:true, first:1, query:"fulfillment_status:partial"){
            edges{
              node{
                id, name,
                fulfillmentOrders {
                  edges { 
                    node {
                      id,
                      lineItems {
                        edges {
                          node {
                            id, remainingQuantity, totalQuantity, sku
                          }
                        }
                      }
                      fulfillments {
                        edges {
                          node {
                            id
                            trackingInfo {
                              number
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
        """
      ) {
        bulkOperation {
          id
          status
        }
        userErrors {
          field
          message
        }
      }
    }

So I found out that totalQuantity in fulfillmentOrders.lineItems is total-refunded so I can just, in my code, make total-remaining to find the fulfilledQuantity.

example:
you have an article with 4 quantity base, you refund 1 and fulfill 1, you will have 3 totalQuantity, 2 remainingQuantity

you fulfill 1 again, you have 3 total, 1 remaining

you refund 1 again, you have 2 total, 0 remaining


The only problem here is that the fulfilledquantity will not be attached to a tracking number as I can't query for 

fulfillmentLineItems {
                              edges {
                                node {
                                  quantity,
                                  lineItem {
                                    sku
                                  }
                                }
                              }
                            }

 in fulfillments because, in a bulk query, you can't have more than 2 nested connections or else you get this error Bulk queries cannot contain connections with a nesting depth greater than 2

This is in version 2023-01 BTW

Elrendio
Shopify Partner
14 0 5

The combination of these two things indeed seems to make it impossible to bulk query LineItem -> tracking info association.

In addition that can't even be done in several runs, because there's no way to query a set of Fulfillment s or FulfillmentOrder s by IDs.

So, what do I do now?

 

AW1234
Shopify Partner
44 7 12

Hi,

you can query for fulfillments and fulfillmentOrders by using "nodes" like this

 

 

 

{
            nodes(ids: ["id1", "id2", ...]) {
              ... on Fulfillment {
                id
              }
            }
          }

 

 

you can query for up to 250 ids at once with "nodes"

 

personnaly I have more ids than that so I use Promise.all in nodejs to query a lot at once (be careful to the cost with graphql if you want to do that)

you can test your queries with the shopify graphql app in your shopify shop