# 504 Gateway Time-out - on GraphQL

**URL:** <https://community.shiphero.com/t/504-gateway-time-out-on-graphql/2555>\
**Category:** GraphQL API\
**Created:** [July 28, 2023, 6:33pm UTC](https://community.shiphero.com/t/504-gateway-time-out-on-graphql/2555 "2023-07-28T18:33:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shikha.agrawal](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shikha.agrawal](https://community.shiphero.com/u/shikha.agrawal)\
**Post date:** [July 28, 2023, 6:33pm UTC](https://community.shiphero.com/t/504-gateway-time-out-on-graphql/2555/1 "2023-07-28T18:33:26Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [July 31, 2023, 12:14pm UTC](https://community.shiphero.com/t/504-gateway-time-out-on-graphql/2555/2 "2023-07-31T12:14:41Z")

</div>

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](https://developer.shiphero.com/graphql-primer/#pagination), but below is a very simple query of adding the after filter to the data you’re trying to pull

```auto
{
  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

---

<div class="post-metadata">

**Author:** ![shikha.agrawal](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@shikha.agrawal](https://community.shiphero.com/u/shikha.agrawal)\
**Post date:** [July 31, 2023, 1:03pm UTC](https://community.shiphero.com/t/504-gateway-time-out-on-graphql/2555/3 "2023-07-31T13:03:35Z")

</div>

Thank you @sh-agent! Will attempt that.

Best,  
Shikha
