Skip to content

Instantly share code, notes, and snippets.

@StarpTech
Last active November 4, 2018 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StarpTech/f3ca437876df284b00005a1078a33705 to your computer and use it in GitHub Desktop.
Save StarpTech/f3ca437876df284b00005a1078a33705 to your computer and use it in GitHub Desktop.
Notes about Caching in GraphQL

Graphql cache challenges

How to practice HTTP Caching?

GraphQL queries are usually POST requests. POST request aren't cached by nature. This means that we need different solutions to deliver our content efficiently.

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 GET requests.
  • 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.

or almost everything in one article...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment