Skip to content

Commit

Permalink
Don't unshim middleware if they aren't shimmed to begin with
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffutter committed Apr 11, 2024
1 parent 7391a24 commit a832a12
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/absinthe/federation/schema/entities_field.ex
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ defmodule Absinthe.Federation.Schema.EntitiesField do
args = convert_keys_to_atom(representation, context)

middleware
|> Absinthe.Middleware.unshim(schema)
|> maybe_unshim(schema)
|> Enum.find(nil, &only_resolver_middleware/1)
|> case do
{_, resolve_ref_func} when is_function(resolve_ref_func, 2) ->
Expand All @@ -187,6 +187,11 @@ defmodule Absinthe.Federation.Schema.EntitiesField do
end
end

def maybe_unshim([{{Absinthe.Middleware, :shim}, {_, _, _}}] = middleware, schema),
do: Absinthe.Middleware.unshim(middleware, schema)

def maybe_unshim(middleware, _schema), do: middleware

defp convert_keys_to_atom(map, context) when is_map(map) do
Map.new(map, fn {k, v} ->
k = convert_key(k, context)
Expand Down

0 comments on commit a832a12

Please sign in to comment.