Class: GraphQL::Client::Definition::DefinitionVisitor

Inherits:
Language::Visitor
  • Object
show all
Defined in:
lib/graphql/client/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(doc) ⇒ DefinitionVisitor

Returns a new instance of DefinitionVisitor.



159
160
161
162
163
164
# File 'lib/graphql/client/definition.rb', line 159

def initialize(doc)
  super
  @spreads = {}
  @definitions = {}
  @current_definition = nil
end

Instance Attribute Details

#definitionsObject (readonly)

Returns the value of attribute definitions.



157
158
159
# File 'lib/graphql/client/definition.rb', line 157

def definitions
  @definitions
end

#spreadsObject (readonly)

Returns the value of attribute spreads.



157
158
159
# File 'lib/graphql/client/definition.rb', line 157

def spreads
  @spreads
end

Instance Method Details

#on_field(node, parent) ⇒ Object



166
167
168
169
170
# File 'lib/graphql/client/definition.rb', line 166

def on_field(node, parent)
  @definitions[node] = @current_definition
  @spreads[node] = get_spreads(node)
  super
end

#on_fragment_definition(node, parent) ⇒ Object



172
173
174
175
176
177
178
179
# File 'lib/graphql/client/definition.rb', line 172

def on_fragment_definition(node, parent)
  @current_definition = node
  @definitions[node] = @current_definition
  @spreads[node] = get_spreads(node)
  super
ensure
  @current_definition = nil
end

#on_inline_fragment(node, parent) ⇒ Object



190
191
192
193
# File 'lib/graphql/client/definition.rb', line 190

def on_inline_fragment(node, parent)
  @definitions[node] = @current_definition
  super
end

#on_operation_definition(node, parent) ⇒ Object



181
182
183
184
185
186
187
188
# File 'lib/graphql/client/definition.rb', line 181

def on_operation_definition(node, parent)
  @current_definition = node
  @definitions[node] = @current_definition
  @spreads[node] = get_spreads(node)
  super
ensure
  @current_definition = nil
end