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