Graphql bulk API connection within a list

I’m trying to get all the refunds for orders that were made between a date range (a month), but this is a heavy query so I decided to use the bulk API. The issue is that it has it’s limitations when it comes to connections inside a list

I get this error

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

when I run this query (simplified version)

{
  orders(query: "createdAt:>'2023-10-01' AND createdAt:<'2023-10-09'", first: 2) {
    pageInfo {
      hasNextPage
    }
    edges {
      node {
        id
        customer {
          id
          email
          firstName
          lastName
          displayName
          phone
          createdAt
          updatedAt
          tags
          image {
            url
          }
        }
        refunds {
          id
          note
          createdAt
          updatedAt
          refundLineItems(first: 20) {
            edges {
              node {
                lineItem {
                  id
                }
              }
            }
          }
        }
      }
    }
  }
}

Basically I don’t know how to get around this unless I get all orders for that time period via the bulk API and then retrieve the refunds order_id by order_id but this kinda defeats the purpose of the bulk API. Any suggestions out there?

Hi Riddleydiddely,

One option could be to get a list of order IDs for the specified date range via the Bulk API (as you suggested) retrieve the list of order IDs from the generated file, and use these order IDs to fetch detailed order information including refunds. Since you cannot directly query nested connections in a bulk operation, perform this step using regular GraphQL queries. You can do this in batches to avoid rate limit issues.

Would this approach work for you? You could also explore using a job queue to handle the detailed information fetching. This way, you can manage API rate limits and process large numbers of orders more efficiently.

I guess, but doesn’t this defeat the whole purpose of the bulk API if I now have to do the bulk API and then also a normal rest/graphql query?

If I understand you correctly I should

  1. Get all orderIds and refund_ids from the bulk query based on my time range
  2. read the JSONL file once it’s finished processing
  3. use the above refund_ids to query refunds? using this?