Class: GraphQL::Client::RenameNodeHook

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

Instance Method Summary collapse

Constructor Details

#initialize(definitions) ⇒ RenameNodeHook

Returns a new instance of RenameNodeHook.



256
257
258
# File 'lib/graphql/client.rb', line 256

def initialize(definitions)
  @definitions = definitions
end

Instance Method Details

#rename_node(node, _parent) ⇒ Object



260
261
262
263
264
265
266
# File 'lib/graphql/client.rb', line 260

def rename_node(node, _parent)
  definition = @definitions[node.name]
  if definition
    node.extend(LazyName)
    node.name_proc = -> { definition.definition_name }
  end
end