interface_type_definition.ex (1470B)
1 defmodule Absinthe.Language.InterfaceTypeDefinition do 2 @moduledoc false 3 4 alias Absinthe.{Blueprint, Language} 5 6 defstruct name: nil, 7 description: nil, 8 fields: [], 9 directives: [], 10 interfaces: [], 11 loc: %{line: nil} 12 13 @type t :: %__MODULE__{ 14 name: String.t(), 15 description: nil | String.t(), 16 fields: [Language.FieldDefinition.t()], 17 directives: [Language.Directive.t()], 18 interfaces: [Language.NamedType.t()], 19 loc: Language.loc_t() 20 } 21 22 defimpl Blueprint.Draft do 23 def convert(node, doc) do 24 %Blueprint.Schema.InterfaceTypeDefinition{ 25 name: node.name, 26 description: node.description, 27 identifier: Macro.underscore(node.name) |> String.to_atom(), 28 fields: Absinthe.Blueprint.Draft.convert(node.fields, doc), 29 directives: Absinthe.Blueprint.Draft.convert(node.directives, doc), 30 interfaces: interfaces(node.interfaces, doc), 31 interface_blueprints: Absinthe.Blueprint.Draft.convert(node.interfaces, doc), 32 source_location: source_location(node) 33 } 34 end 35 36 defp interfaces(interfaces, doc) do 37 interfaces 38 |> Absinthe.Blueprint.Draft.convert(doc) 39 |> Enum.map(&(&1.name |> Macro.underscore() |> String.to_atom())) 40 end 41 42 defp source_location(%{loc: nil}), do: nil 43 defp source_location(%{loc: loc}), do: Blueprint.SourceLocation.at(loc) 44 end 45 end