operation_definition.ex (1272B)
1 defmodule Absinthe.Language.OperationDefinition do 2 @moduledoc false 3 4 alias Absinthe.{Blueprint, Language} 5 6 defstruct operation: nil, 7 name: nil, 8 variable_definitions: [], 9 directives: [], 10 selection_set: nil, 11 shorthand: false, 12 loc: %{line: nil} 13 14 @type t :: %__MODULE__{ 15 operation: :query | :mutation | :subscription, 16 name: nil | String.t(), 17 variable_definitions: [Language.VariableDefinition.t()], 18 directives: [Language.Directive.t()], 19 selection_set: Language.SelectionSet.t(), 20 shorthand: boolean(), 21 loc: Language.loc_t() 22 } 23 24 defimpl Blueprint.Draft do 25 def convert(node, doc) do 26 %Blueprint.Document.Operation{ 27 name: node.name, 28 type: node.operation, 29 directives: Absinthe.Blueprint.Draft.convert(node.directives, doc), 30 variable_definitions: Blueprint.Draft.convert(node.variable_definitions, doc), 31 selections: Blueprint.Draft.convert(node.selection_set.selections, 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 end 39 end