I’m experimenting with the CraftQL plugin and React with Craft 3, and I’m really liking the similar syntax to standard Twig element queries, and the fact I don't need to manually configure API endpoints as I would if I was to set up a REST API using the ElementAPI plugin.

However, I'm not certain how I can cache data using this approach to prevent unnecessary database calls, and the scalability of such a solution.

Using a REST API I'd be able to cache the endpoints using Nginx or Varnish, but this doesn't seem to be an option using GraphQL. There seem to be several options for GraphQL application-level caching in the Node ecosystem (e.g. https://github.com/apollographql/apollo-cache-control).

Are there any options for caching database queries using the Yii Query Caching functionality (http://www.yiiframework.com/doc-2.0/guide-caching-data.html)?

Or any other techniques that may help an implementation like this scale?

  • I think you should ask the creator of the plugin directly. While we can offer help with everything related to Craft we don't know the plugins code and we would have to dig into the source code in order to get to know if there are special caching options other than Craft and Yii2 provides – Robin Schambach Mar 17 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.