Current section

Files

Jump to
absinthe lib absinthe blueprint schema directive_definition.ex
Raw

lib/absinthe/blueprint/schema/directive_definition.ex

defmodule Absinthe.Blueprint.Schema.DirectiveDefinition do
@moduledoc false
alias Absinthe.Blueprint
@enforce_keys [:name]
defstruct [
:name,
:module,
:identifier,
description: nil,
directives: [],
arguments: [],
locations: [],
source_location: nil,
expand: nil,
errors: [],
__reference__: nil,
__private__: []
]
@type t :: %__MODULE__{
name: String.t(),
description: nil,
arguments: [Blueprint.Schema.InputValueDefinition.t()],
locations: [String.t()],
source_location: nil | Blueprint.SourceLocation.t(),
errors: [Absinthe.Phase.Error.t()]
}
def build(type_def, schema) do
%Absinthe.Type.Directive{
name: type_def.name,
identifier: type_def.identifier,
description: type_def.description,
args: Blueprint.Schema.ObjectTypeDefinition.build_args(type_def, schema),
locations: type_def.locations |> Enum.sort(),
definition: type_def.module,
expand: type_def.expand
}
end
@doc false
def functions(), do: [:expand]
defimpl Inspect do
defdelegate inspect(term, options),
to: Absinthe.Schema.Notation.SDL.Render
end
end