504 Gateway Time-out at Pagination (Orders)

Hey!

We are paginating through the Orders with the GraphQL API, and lots of our requests end up in 504 Gateway Time-out errors. We queried many fields on the Order object, some sub pages (like attachment), etc. But when we saw these timeouts, after a lots of trial and error, we reduced the query to the smallest we could. So we ended up a with query like this. But this query still results a 504 Gateway Time-out most of the times.

query Orders(
    $updatedFrom: ISODateTime
    $first: Int
) {
    orders(updated_from: $updatedFrom) {
        data(first: $first) {
            edges {
                node {
                    ...OrderFragment
                }
            }
            pageInfo {
                hasNextPage
                endCursor
            }
        }
    }
}

fragment OrderFragment on Order {
    id
}

Variables:

{
    "updatedFrom": "2025-08-29T12:44:06.000Z",
    "first": 1
}

Now I am out of ideas what could I try to get a reliable response.

We must use the updated_from, because we don’t want to query all the orders. But I also tried without this filter, and that also timed out. We cannot reduce the page count (first) under 1. We also tried with Exponential Backoff (wait 1-5-10+ mins and retry) logic, but that didn’t help either.

Do you have any recommendations? Thanks in advance!