Skip to content

Commit

Permalink
Simplify type resolution invariants.
Browse files Browse the repository at this point in the history
Co-authored-by: Doruk Gurleyen <dorukgurleyen@gmail.com>
  • Loading branch information
TannerRogalsky and kzlsakal authored Jan 9, 2025
1 parent 156dcd1 commit e72385f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/absinthe/federation/schema/entity_union.ex
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,16 @@ defimpl Absinthe.Federation.Schema.EntityUnion.Resolver, for: Any do
defp inner_resolve_type(data, typename, resolution) do
type = Absinthe.Schema.lookup_type(resolution.schema, typename)

if is_nil(type) do
to_internal_name(typename, resolution.adapter)
else
if(Map.has_key?(type, :resolve_type)) do
case type do
%{resolve_type: resolve_type} when not is_nil(resolve_type) ->
resolver = Absinthe.Type.function(type, :resolve_type)
resolver.(data, resolution)

if is_nil(resolver) do
to_internal_name(typename, resolution.adapter)
else
resolver.(data, resolution)
end
else
_type ->
to_internal_name(typename, resolution.adapter)
end
end
end
end

defp to_internal_name(name, adapter) when is_nil(adapter) do
name
Expand Down

0 comments on commit e72385f

Please sign in to comment.