Cloudfront cache with GraphQL?

Question:

At my company we’re using graphql for production apps, but only for private ressources.

For now our public APIs are REST APIs with a Cloudfront service for cache. We want to transform them as GraphQL APIs, but the question is : how to handle cache properly with GraphQL ?

We thought using a GET graphql endpoint, and cache on querystring but we are a bit affraid of the size of the URL requested (as we support IE9+ and sell to schools with sometime really dummy proxy and firewalls)

So we would like to use POST graphQL endpoint but…cloudfront cannot cache a request based on its body

Anyone has an idea / best practice to share ?
Thanks

Answer:

The two best options today are:

  • Use a specialized caching solution, like FastQL.io
  • Use persisted queries with GET, where some queries are saved on your server and accessed by name via GET

*Full disclosure: I started FastQL after running into these issues without a good solution.

Leave a Reply