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