AbsintheCacheFairy.DocumentProvider (absinthe_cache_fairy v0.2.0)
Custom Absinthe DocumentProvider for more effective caching.
Absinthe phases have one main difference in comparison to plugs - all phases
must run and cannot be halted. But phases can be jumped over by returning
{:jump, result, destination_phase}
This module makes use of 2 new phases - a CacheDocument phase and Idempotent
phase.
If the value is present in the cache, it is put in the blueprint and the execution
jumps to the Idempotent phase, effectively skipping the Absinthe's Resolution
and Result phases. Result is the last phase in the pipeline, thus the Idempotent
phase is inserted after it.
If the value is not present in the cache, the Absinthe's default Resolution and
Result phases are being executed and the new DocumentCache and Idempotent
phases are no-op.
Finally, there's a before_send hook that adds the result into the cache.