Skip to content

Commit

Permalink
fix: make sure we respect config disables in the middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaAK committed Oct 11, 2023
1 parent 173db09 commit 9b3ecc3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/request_cache/middleware.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9b3ecc3

Please sign in to comment.