From 9b3ecc3d5de588063f83139b3520dce087df3338 Mon Sep 17 00:00:00 2001 From: MikaAK Date: Wed, 11 Oct 2023 16:11:30 -0700 Subject: [PATCH] fix: make sure we respect config disables in the middleware --- lib/request_cache/middleware.ex | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/request_cache/middleware.ex b/lib/request_cache/middleware.ex index 56bfae4..e438ac4 100644 --- a/lib/request_cache/middleware.ex +++ b/lib/request_cache/middleware.ex @@ -10,12 +10,20 @@ if absinthe_loaded? do def call(%Absinthe.Resolution{} = resolution, opts) when is_list(opts) do opts = ensure_valid_ttl(opts) - enable_cache_for_resolution(resolution, opts) + if RequestCache.Config.enabled?() do + enable_cache_for_resolution(resolution, opts) + else + resolution + end end @impl Absinthe.Middleware def call(%Absinthe.Resolution{} = resolution, ttl) when is_integer(ttl) do - enable_cache_for_resolution(resolution, ttl: ttl) + if RequestCache.Config.enabled?() do + enable_cache_for_resolution(resolution, ttl: ttl) + else + resolution + end end defp ensure_valid_ttl(opts) do