Graphql cache challenges
How to practice HTTP Caching?
GraphQL queries are usually
POST request aren't cached by nature. This means that we need different solutions to deliver our content efficiently.
Automatic persisted queries (APQs) is a performance technique which allows a hash to be sent to the server instead of the entire GraphQL query string. It is possible to use APQs with
GETrequests here. In that way we can also benefit from CDN. How it works. In theory it's the same mechanism as the
etagheader but on server-side.
How deduplicating database calls?
- DataLoader is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching. Here you can find a simple example.
How to take advantage of CDN's ?
- Automatic persisted queries allows us to use cacheable
- There are also native GraphQL CDN's like Fastql.
How to integrate REST Apis?
Read the article it shows in few examples how we can efficiently integrate REST API with GraphQL. It takes all points like HTTP caching, introspection and authorization into account. If you need a more comprehensive overview see here.