class GraphQL::InternalRepresentation::Rewrite::VisitDefinition
Public Class Methods
new(context, definitions, nodes_stack, scopes_stack)
click to toggle source
# File lib/graphql/internal_representation/rewrite.rb, line 164 def initialize(context, definitions, nodes_stack, scopes_stack) @context = context @query = context.query @definitions = definitions @nodes_stack = nodes_stack @scopes_stack = scopes_stack end
Public Instance Methods
enter(ast_node, ast_parent)
click to toggle source
# File lib/graphql/internal_representation/rewrite.rb, line 172 def enter(ast_node, ast_parent) # Either QueryType or the fragment type condition owner_type = @context.type_definition && @context.type_definition.unwrap defn_name = ast_node.name node = Node.new( parent: nil, name: defn_name, owner_type: owner_type, query: @query, ast_nodes: [ast_node], return_type: @context.type_definition, ) @definitions[defn_name] = node @scopes_stack.push(Scope.new(@query, owner_type)) @nodes_stack.push([node]) end
leave(ast_node, ast_parent)
click to toggle source
# File lib/graphql/internal_representation/rewrite.rb, line 191 def leave(ast_node, ast_parent) @nodes_stack.pop @scopes_stack.pop end