How to implement caching on an Absinthe based solution?

Hello Everyone,

I’ve learned that I can use ETS tables as a basic cache mechanism to expedite data queries in Elixir and Phoenix. And, other more advanced solutions (CacheX, ConCache) use ETS under the hood. However, what about if I’m using Absinthe to build a GraphQL API? None of the tutorials I’ve seen talk about caching. They just show you how to connect Absinthe to Ecto and a database.

Is there a way to tell Absinthe to read from ETS, or another cache? Should I use one of Absinthe plugins to help me with that?

Please notice that I’d like to be able to load specific data in memory. So, even if Absinthe has some kind of internal cache, that won’t help in this case.

Thank you


I’d probably load from cache in the resolver and/or in the “context”. I’m not sure it would be any different if there wasn’t absinthe/graphql. Dataloader could also probably be used with a (maybe custom) cache “source”.


I see. I was associating revolvers to only mutations. You’re saying I can use them to specify the source of data for a query. Correct?

You’re saying I can use them to specify the source of data for a query. Correct?

Including that, yes. Resolvers “resolve” the query to data, so they can do almost anything they want. Akin to a controller action in phoenix.

OK. I definitely need to read my copy of “Craft GraphQL APIs in Elixir with Absinthe” :slight_smile:

Thank you

That is what I was thinking when I mentioned plugins before. Especially Dataloader.KV seems like a perfect match for ETS, but after recognizing resolvers can read from cache as well, that seems like an easier solution