Can Absinthe Blueprint be cached?

As this picture from the “Craft GraphQL APIs in Elixir with Absinthe” shows, each time Absinthe is passed a GraphQL document it goes through these steps, like an interpreter.

Since Absinthe already supports persisted queries - caching of the GraphQL documents, I’m wondering whether it’s possible to go further and cache the blueprints, which should save a lot of processing time.


Persisted queries, using the Absinthe.Plug.DocumentProvider.Compiled module as a base, are doing exactly that: executing the pipeline down to the %Absinthe.Blueprint{} struct, and storing this as compiled code.

When a query comes in, it is looked up in the resulting map using the persisted query id, and the fetched Blueprint used as the start of the evaluation pipeline, instead of the raw query text.

The nice thing is that it is prepared (and therefore validity checked) at compile time (macros), rather than ‘cached’ at run-time. Take a look at the above mentioned module in absinthe_plug for details.


Thanks! That’s really interesting.