Skip to content

Commit

Permalink
Always exclude __typename
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryseed committed Jan 1, 2021
1 parent 4a936a6 commit 16553d0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/absinthe/phase/schema/field_imports.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ defmodule Absinthe.Phase.Schema.FieldImports do
Schema.InputObjectTypeDefinition,
Schema.InterfaceTypeDefinition
]
@exclude_fields [
:__typename
]
def import_fields(%def_type{} = type, types) when def_type in @can_import do
Enum.reduce(type.imports, type, fn {source, opts}, type ->
source_type = Map.fetch!(types, source)

rejections = Keyword.get(opts, :except, []) ++ exclusions(type)
rejections = Keyword.get(opts, :except, []) ++ @exclude_fields

fields = source_type.fields |> Enum.reject(&(&1.identifier in rejections))

Expand All @@ -51,7 +54,4 @@ defmodule Absinthe.Phase.Schema.FieldImports do
end

def import_fields(type, _), do: type

defp exclusions(%Schema.InputObjectTypeDefinition{}), do: [:__typename]
defp exclusions(_), do: []
end

0 comments on commit 16553d0

Please sign in to comment.