123456789_123456789_123456789_123456789_123456789_

Class: GraphQL::Client::RenameNodeVisitor

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, GraphQL::Language::Visitor
Instance Chain:
self, GraphQL::Language::Visitor
Inherits: GraphQL::Language::Visitor
  • Object
Defined in: lib/graphql/client.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(document, definitions:) ⇒ RenameNodeVisitor

[ GitHub ]

  
# File 'lib/graphql/client.rb', line 237

def initialize(document, definitions:)
  super(document)
  @definitions = definitions
end

Instance Method Details

#on_fragment_definition(node, _parent)

[ GitHub ]

  
# File 'lib/graphql/client.rb', line 242

def on_fragment_definition(node, _parent)
  rename_node(node)
  super
end

#on_fragment_spread(node, _parent)

[ GitHub ]

  
# File 'lib/graphql/client.rb', line 252

def on_fragment_spread(node, _parent)
  rename_node(node)
  super
end

#on_operation_definition(node, _parent)

[ GitHub ]

  
# File 'lib/graphql/client.rb', line 247

def on_operation_definition(node, _parent)
  rename_node(node)
  super
end

#rename_node(node) (private)

[ GitHub ]

  
# File 'lib/graphql/client.rb', line 259

def rename_node(node)
  definition = @definitions[node.name]
  if definition
    node.extend(LazyName)
    node._definition = definition
  end
end