Solving GraphQL Caching with Hasura

·

1 min read

Hasura recently opened up GraphQL caching on their free tier. With this, it's possible to get faster response times by adding caching to existing GraphQL APIs.

GraphQL Caching is hard

With GraphQL being transport-agnostic, nearly all server implementations use the HTTP REST API style for making requests. And this impacts caching because all the requests are HTTP POST as GraphQL isn't able to leverage the existing patterns that are already there for REST APIs.

And since GET requests have query string size limitations, GraphQL queries are slowed down because of the size of the response or the location of the server, or the number of concurrent API calls.

GraphQL Caching with Hasura

Hasura allows for GraphQL caching out-of-the-box. Hasura is able to cache a GraphQL query's response if the query is from any external GraphQL server added via a Hasura feature called Remote Schema, or if session variables aren't used, then authenticated queries can be cached, and Hasura is able to cache responses in JSON up unto 100KB in size.

Hasura has the following features when it comes to GraphQL caching: