Class: GraphQL::InternalRepresentation::Rewrite::VisitDefinition
- Inherits:
-
Object
- Object
- GraphQL::InternalRepresentation::Rewrite::VisitDefinition
- Defined in:
- lib/graphql/internal_representation/rewrite.rb
Instance Method Summary collapse
- #enter(ast_node, ast_parent) ⇒ Object
-
#initialize(context, definitions, nodes_stack, scopes_stack) ⇒ VisitDefinition
constructor
A new instance of VisitDefinition.
- #leave(ast_node, ast_parent) ⇒ Object
Constructor Details
#initialize(context, definitions, nodes_stack, scopes_stack) ⇒ VisitDefinition
Returns a new instance of VisitDefinition.
156 157 158 159 160 161 162 |
# File 'lib/graphql/internal_representation/rewrite.rb', line 156 def initialize(context, definitions, nodes_stack, scopes_stack) @context = context @query = context.query @definitions = definitions @nodes_stack = nodes_stack @scopes_stack = scopes_stack end |
Instance Method Details
#enter(ast_node, ast_parent) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/graphql/internal_representation/rewrite.rb', line 164 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: owner_type, ) @definitions[defn_name] = node @scopes_stack.push(Scope.new(@query, owner_type)) @nodes_stack.push([node]) end |
#leave(ast_node, ast_parent) ⇒ Object
183 184 185 186 |
# File 'lib/graphql/internal_representation/rewrite.rb', line 183 def leave(ast_node, ast_parent) @nodes_stack.pop @scopes_stack.pop end |