Current section

Files

Jump to
absinthe lib absinthe language variable_definition.ex
Raw

lib/absinthe/language/variable_definition.ex

defmodule Absinthe.Language.VariableDefinition do
@moduledoc false
alias Absinthe.{Blueprint, Language}
defstruct variable: nil,
type: nil,
directives: [],
default_value: nil,
loc: %{line: nil}
@type t :: %__MODULE__{
variable: Language.Variable.t(),
type: Language.type_reference_t(),
default_value: any,
loc: Language.loc_t()
}
defimpl Blueprint.Draft do
def convert(node, doc) do
%Blueprint.Document.VariableDefinition{
name: node.variable.name,
type: Blueprint.Draft.convert(node.type, doc),
directives: Absinthe.Blueprint.Draft.convert(node.directives, doc),
default_value: Blueprint.Draft.convert(node.default_value, doc),
source_location: source_location(node)
}
end
defp source_location(%{loc: nil}), do: nil
defp source_location(%{loc: loc}), do: Blueprint.SourceLocation.at(loc)
end
end