504 Gateway Time-out - on GraphQL

Hello,

We are seeing an increase in 504 error when using GraphQL. We already have retry with exponential backoff built in, so the issue is very frequent on some days.

Like on July 24th, we encountered the issue between 1 PM and 10 PM consistently. July 25 the same pattern.

Here is the timestamp from one of the errors:
Jul 25, 2023 at 19:33:38.569 EST

Exact error:
Gateway Timeout |

504 Gateway Time-out

504 Gateway Time-out

URL called: POST https://public-api.shiphero.com/graphql

query payload:
{“query”:“{ \n shipments (\n date_from: "2023-07-25 00:00:00",\n date_to : "2023-07-25 23:59:59"\n ) {\n request_id\n complexity\n data(first: 1000) {\n pageInfo {\n hasNextPage\n hasPreviousPage\n startCursor\n endCursor\n }\n \n edges {\n node {\n id\n legacy_id\n order_id\n order {\n order_number\n }\n warehouse_id\n completed\n needs_refund\n refunded\n delivered\n dropshipment\n created_date\n shipping_labels {\n id\n legacy_id\n shipment_id\n tracking_number\n carrier\n shipping_name\n shipping_method\n address {\n name\n address1\n address2\n city\n state\n country\n zip\n }\n dimensions {\n weight\n height\n width\n length\n }\n cost\n profile\n warehouse\n insurance_amount\n source\n created_date\n }\n }\n }\n \n }\n }\n }”}

Wondering if you could shed some light on this.

Thanks,
Shikha

Hey @shikha.agrawal,

Thanks for reaching out and welcome to our Developer Community!

I believe that you’re trying to pull too much information initially. I would recommend pulling 100 shipments instead of 1000 to begin with and paginating the results. This should also greatly speed up the length of time it takes the query to execute.

You can read more about pagination here: GraphQL Primer – Developer Resources | ShipHero, but below is a very simple query of adding the after filter to the data you’re trying to pull

{
  shipments(date_from: "2023-07-25 00:00:00", date_to: "2023-07-25 23:59:59") {
    request_id
    complexity
    data(after: "string", first: 100) {
      pageInfo {
        hasNextPage
        hasPreviousPage
        startCursor
        endCursor
      }
      edges {
        node {
          id
        }
      }
    }
  }
}

The after string should be replaced with the value returned by endCursor.

Please let me know if this helps!

Best,
RayanP

Thank you @sh-agent! Will attempt that.

Best,
Shikha

1 Like