- Newest
- Most votes
- Most comments
Here are two viable solutions to overcome query string length limitations when handling large GraphQL queries behind Amazon CloudFront:
-
Switch to POST Requests. Bypass CloudFront's query string limits by including the GraphQL query in the request body. This ensures compatibility with arbitrarily large queries. Please note that CloudFront doesn't cache POST requests. If caching is crucial for your application, an alternative approach may be necessary.
-
Implement Automatic Persisted Queries (APQ). APQ significantly reduces query string size by replacing full queries with unique identifiers after initial persistence. This drastically minimizes the chance of exceeding CloudFront's limits and enhances performance. On the other hand, it requires integration on both the server (to support APQ) and the client. See Apollo implementation at https://www.apollographql.com/docs/apollo-server/performance/apq/.
The choice between these options depends on your application's specific needs and constraints. If caching is not a primary concern and client-side adjustments are feasible, switching to POST requests provides a straightforward solution. If performance optimization and minimizing query string size are priorities, investing in APQ integration offers a robust, long-term solution.
Relevant content
- asked 4 months ago
- asked 2 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 6 months ago