GraphQL Caching Demystified - Matteo Collina, GraphQL Galaxy 2021

Discover the secrets to GraphQL caching, explore strategies and tools to improve query performance, including caching systems, auto-pipelining, and Mercurius features, as well as best practices to optimize and speed up your GraphQL requests.

Key takeaways
  • Use a caching system, such as Redis, to improve performance of GraphQL queries.
  • Auto-pipelining and caching validations are key strategies for improving performance.
  • Mercurius, a GraphQL adapter, offers interesting features for caching.
  • Caching keys can be computed based on the query, request, and current field selection.
  • Implementing a cache with a TTL (time to live) can improve performance.
  • Use of JSON.stringify to create a cache key can be problematic and slower.
  • Using a library like safe stable stringify can improve performance.
  • Parallelizing Redis gets can improve performance.
  • Implementing a connection pool can improve performance.
  • AutoCannon is a tool for running load tests in JavaScript.
  • Fastify is a fast web framework for Node.js that can be used with GraphQL.
  • The anatomy of a solver includes the root, arguments, and info object.
  • The event loop is an important concept to understand in Node.js.
  • Flame graphs can be used to visualize the performance of an application.
  • Implementing a caching system can improve performance by reducing HTTP requests and round trip times.