Unable to to query Orders via BulkOperation

Hi team,
I’m using this query via bulkOperations and getting the following error.
'Queries that contain a connection field within a list field are not currently supported.'

Query:

query {
    orders  {
        edges {
            node {
                name
                id
                createdAt
                lineItems {
                    edges {
                        node {
                            variant {
                                id
                            }
                            title
                            sku
                            quantity
                            discountedUnitPriceAfterAllDiscountsSet {
                                presentmentMoney {
                                    amount
                                    currencyCode
                                }
                            }
                            originalUnitPriceSet {
                                presentmentMoney {
                                    amount
                                    currencyCode
                                }
                            }
                        }
                    }
                }
                netPaymentSet {
                    presentmentMoney {
                        amount
                        currencyCode
                    }
                }
                refunds {
                    refundLineItems {
                        edges {
                            node {
                                lineItem {
                                    variant {
                                        id
                                    }
                                }
                                quantity
                            }
                        }
                    }
                }
            }
        }
    }
}

Error:

{
    'data': {
        'bulkOperationRunQuery': {
            'bulkOperation': None, 
            'userErrors': [
                    {
                        'message': 'Queries that contain a connection field within a list field are not currently supported.', 
                        'field': ['query']
                    }
                ]
        }
    }
}

Any solution to over come this limitation?

As far as I know you cannot query the refund line items. The only solution I have found is to just query each individual refund itself (same with fulfillments). You have to be careful not to get throttled out by tracking points and it is slow but as far as I know it is the only solution. I’m not sure what batching is here but batching by id into a single call doesn’t reduce the points AFAIK or that is what the docs state.

1 Like

These are the docs that mention that combining operations into a single request provides no benefits to the caller/requester: Advanced concepts

Submitting multiple queries or mutations in a single request doesn’t provide rate-limiting benefits, because the operation complexities are additive.

@dogowner
Thank you for these suggestions. I will look into these.

hey @Ashwath_M :slight_smile:
did you find any solution for this limit using the bulkOperation?

@Esti_Zeldman, as @dogowner mentioned shopify does not support queries that contains a list filed like refundLineItems.

For now I have split this operation into two parts:

  1. Query the orders as a bulkOperation with this query:
query = """
            query {
                orders {
                    edges {
                        node {
                            name
                            id
                            createdAt
                            updatedAt
                            currencyCode
                            lineItems {
                                edges {
                                    node {
                                        variant {
                                            id
                                        }
                                        title
                                        sku
                                        quantity
                                        originalUnitPriceSet {
                                            presentmentMoney {
                                                amount
                                            }
                                        }
                                        discountedUnitPriceAfterAllDiscountsSet {
                                            presentmentMoney {
                                                amount
                                            }
                                        }
                                        taxable
                                        taxLines {
                                            title
                                            priceSet {
                                                presentmentMoney {
                                                    amount
                                                }
                                            }
                                            rate
                                            ratePercentage
                                        }
                                    }
                                }
                            }
                            currentShippingPriceSet {
                                presentmentMoney {
                                    amount
                                }
                            }
                            refunds {
                                id
                            }
                        }
                    }
                }
            }
        """
  1. You would get the refund ids in the above query and simply make individual request to get the details of the refund. This is still not the cleanest solution because you can just query the first 250 refundLineItems in this query.
refund_query = """
            query refund($id: ID!) {
                refund(id: $id){
                    id
                    order {
                        id
                    }
                    refundLineItems(first: 250) {
                        edges{
                            node{
                                lineItem {
                                    variant {
                                        id
                                    }
                                }
                                quantity
                            }
                        }
                    }
                }
            }
        """

And finally you join the result of both these queries using the variant id and the order id