module GraphQL::StaticValidation::BaseVisitor::ContextMethods
Constants
- INLINE_FRAGMENT_NO_TYPE
Public Instance Methods
# File lib/graphql/static_validation/base_visitor.rb, line 254 def argument_definition # Return the parent argument definition (not the current one). @parent_argument_definition end
Returns
-
GraphQL::Argument, nil— The most-recently-entered GraphQL::Argument, if currently inside one
Source
# File lib/graphql/static_validation/base_visitor.rb, line 200 def child_positions(parent) @child_positions[parent] ||= begin positions = {}.compare_by_identity parent.children.each_with_index { |child, index| positions[child] ||= index } positions end end
# File lib/graphql/static_validation/base_visitor.rb, line 244 def directive_definition @current_directive_definition end
Returns
-
GraphQL::Directive, nil— The most-recently-entered GraphQL::Directive, if currently inside one
# File lib/graphql/static_validation/base_visitor.rb, line 234 def field_definition @current_field_definition end
Returns
-
GraphQL::Field, nil— The most-recently-entered GraphQL::Field, if currently inside one
Source
# File lib/graphql/static_validation/base_visitor.rb, line 153 def on_argument(node, parent) argument_defn = if (arg = @current_argument_definition) arg_type = arg.type.unwrap if arg_type.kind.input_object? @types.argument(arg_type, node.name) else nil end elsif (directive_defn = @current_directive_definition) @types.argument(directive_defn, node.name) elsif (field_defn = @current_field_definition) @types.argument(field_defn, node.name) else nil end prev_parent = @parent_argument_definition @parent_argument_definition = @current_argument_definition @current_argument_definition = argument_defn @path[@path_depth] = node.name @path_depth += 1 super @current_argument_definition = @parent_argument_definition @parent_argument_definition = prev_parent @path_depth -= 1 @child_positions.delete(node) end
Calls superclass method
Source
# File lib/graphql/static_validation/base_visitor.rb, line 145 def on_directive(node, parent) directive_defn = @context.schema_directives[node.name] prev_directive_definition = @current_directive_definition @current_directive_definition = directive_defn super @current_directive_definition = prev_directive_definition end
Calls superclass method
Source
# File lib/graphql/static_validation/base_visitor.rb, line 124 def on_field(node, parent) parent_type = @current_object_type field_definition = @types.field(parent_type, node.name) prev_field_definition = @current_field_definition @current_field_definition = field_definition prev_parent_ot = @parent_object_type @parent_object_type = @current_object_type if field_definition @current_object_type = @field_unwrapped_types[field_definition] ||= field_definition.type.unwrap else @current_object_type = nil end @path[@path_depth] = node.alias || node.name @path_depth += 1 super @current_field_definition = prev_field_definition @current_object_type = @parent_object_type @parent_object_type = prev_parent_ot @path_depth -= 1 end
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 86 def on_fragment_definition(node, parent) object_type = if node.type @types.type(node.type.name) else @current_object_type end prev_parent_ot = @parent_object_type @parent_object_type = @current_object_type @current_object_type = object_type @path[@path_depth] = "fragment #{node.name}" @path_depth += 1 super @current_object_type = @parent_object_type @parent_object_type = prev_parent_ot @path_depth -= 1 end
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 181 def on_fragment_spread(node, parent) @path[@path_depth] = "... #{node.name}" @path_depth += 1 super @path_depth -= 1 end
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 105 def on_inline_fragment(node, parent) if node.type object_type = @types.type(node.type.name) @path[@path_depth] = @inline_fragment_paths[node.type.name] ||= -"... on #{node.type.to_query_string}" @path_depth += 1 else object_type = @current_object_type @path[@path_depth] = INLINE_FRAGMENT_NO_TYPE @path_depth += 1 end prev_parent_ot = @parent_object_type @parent_object_type = @current_object_type @current_object_type = object_type super @current_object_type = @parent_object_type @parent_object_type = prev_parent_ot @path_depth -= 1 end
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 188 def on_input_object(node, parent) arg_defn = @current_argument_definition if arg_defn && arg_defn.type.list? @path[@path_depth] = child_positions(parent)[node] @path_depth += 1 super @path_depth -= 1 else super end end
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 73 def on_operation_definition(node, parent) object_type = @schema.root_type_for_operation(node.operation_type) prev_parent_ot = @parent_object_type @parent_object_type = @current_object_type @current_object_type = object_type @path[@path_depth] = "#{node.operation_type}#{node.name ? " #{node.name}" : ""}" @path_depth += 1 super @current_object_type = @parent_object_type @parent_object_type = prev_parent_ot @path_depth -= 1 end
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 224 def parent_type_definition @parent_object_type end
Returns
-
GraphQL::BaseType— The type which the current type came from
# File lib/graphql/static_validation/base_visitor.rb, line 214 def type_definition @current_object_type end
Returns
-
GraphQL::BaseType— The current object type