interface_type_definition.ex (1714B)
1 defmodule Absinthe.Blueprint.Schema.InterfaceTypeDefinition do 2 @moduledoc false 3 4 alias Absinthe.Blueprint 5 alias Absinthe.Blueprint.Schema 6 7 @enforce_keys [:name] 8 defstruct [ 9 :identifier, 10 :name, 11 :module, 12 description: nil, 13 fields: [], 14 directives: [], 15 interfaces: [], 16 interface_blueprints: [], 17 source_location: nil, 18 # Added by phases 19 flags: %{}, 20 errors: [], 21 resolve_type: nil, 22 imports: [], 23 __reference__: nil, 24 __private__: [] 25 ] 26 27 @type t :: %__MODULE__{ 28 name: String.t(), 29 description: nil | String.t(), 30 fields: [Blueprint.Schema.FieldDefinition.t()], 31 directives: [Blueprint.Directive.t()], 32 interfaces: [String.t()], 33 interface_blueprints: [Blueprint.Draft.t()], 34 source_location: nil | Blueprint.SourceLocation.t(), 35 # Added by phases 36 flags: Blueprint.flags_t(), 37 errors: [Absinthe.Phase.Error.t()] 38 } 39 40 def build(type_def, schema) do 41 %Absinthe.Type.Interface{ 42 name: type_def.name, 43 description: type_def.description, 44 fields: Blueprint.Schema.ObjectTypeDefinition.build_fields(type_def, schema), 45 identifier: type_def.identifier, 46 resolve_type: type_def.resolve_type, 47 definition: type_def.module, 48 interfaces: type_def.interfaces 49 } 50 end 51 52 def find_implementors(iface, type_defs) do 53 for %Schema.ObjectTypeDefinition{} = obj <- type_defs, 54 iface.identifier in obj.interfaces, 55 do: obj.identifier 56 end 57 58 @doc false 59 def functions(), do: [:resolve_type] 60 61 defimpl Inspect do 62 defdelegate inspect(term, options), 63 to: Absinthe.Schema.Notation.SDL.Render 64 end 65 end