directive_definition.ex (1315B)
1 defmodule Absinthe.Blueprint.Schema.DirectiveDefinition do 2 @moduledoc false 3 4 alias Absinthe.Blueprint 5 6 @enforce_keys [:name] 7 defstruct [ 8 :name, 9 :module, 10 :identifier, 11 description: nil, 12 directives: [], 13 arguments: [], 14 locations: [], 15 repeatable: false, 16 source_location: nil, 17 expand: nil, 18 errors: [], 19 __reference__: nil, 20 __private__: [] 21 ] 22 23 @type t :: %__MODULE__{ 24 name: String.t(), 25 description: nil, 26 arguments: [Blueprint.Schema.InputValueDefinition.t()], 27 locations: [String.t()], 28 repeatable: boolean(), 29 source_location: nil | Blueprint.SourceLocation.t(), 30 errors: [Absinthe.Phase.Error.t()] 31 } 32 33 def build(type_def, schema) do 34 %Absinthe.Type.Directive{ 35 name: type_def.name, 36 identifier: type_def.identifier, 37 description: type_def.description, 38 args: Blueprint.Schema.ObjectTypeDefinition.build_args(type_def, schema), 39 locations: type_def.locations |> Enum.sort(), 40 definition: type_def.module, 41 repeatable: type_def.repeatable, 42 expand: type_def.expand 43 } 44 end 45 46 @doc false 47 def functions(), do: [:expand] 48 49 defimpl Inspect do 50 defdelegate inspect(term, options), 51 to: Absinthe.Schema.Notation.SDL.Render 52 end 53 end