Class: Graphlyte::Syntax::VariableReference

Inherits:
Data
  • Object
show all
Defined in:
lib/graphlyte/syntax.rb

Overview

A use of a variable in an operation or fragment See: spec.graphql.org/October2021/#Variable

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Data

#==, attr_accessor, attr_reader, attributes, #dup, #eql?, #hash, #inspect

Constructor Details

#initialize(variable = nil, inferred_type = nil, **kwargs) ⇒ VariableReference

Returns a new instance of VariableReference.



148
149
150
151
152
# File 'lib/graphlyte/syntax.rb', line 148

def initialize(variable = nil, inferred_type = nil, **kwargs)
  super(**kwargs)
  @variable ||= variable
  @inferred_type ||= inferred_type
end

Instance Attribute Details

#inferred_typeObject

Returns the value of attribute inferred_type.



146
147
148
# File 'lib/graphlyte/syntax.rb', line 146

def inferred_type
  @inferred_type
end

#variableObject

Returns the value of attribute variable.



146
147
148
# File 'lib/graphlyte/syntax.rb', line 146

def variable
  @variable
end

Instance Method Details

#to_definitionObject



154
155
156
# File 'lib/graphlyte/syntax.rb', line 154

def to_definition
  VariableDefinition.new(variable: variable, type: inferred_type)
end