module GraphQL::StaticValidation::BaseVisitor::ContextMethods
Public Instance Methods
argument_definition()
click to toggle source
@return [GraphQL::Argument, nil] The most-recently-entered GraphQL::Argument
, if currently inside one
# File lib/graphql/static_validation/base_visitor.rb, line 180 def argument_definition # Don't get the _last_ one because that's the current one. # Get the second-to-last one, which is the parent of the current one. @argument_definitions[-2] end
directive_definition()
click to toggle source
@return [GraphQL::Directive, nil] The most-recently-entered GraphQL::Directive
, if currently inside one
# File lib/graphql/static_validation/base_visitor.rb, line 175 def directive_definition @directive_definitions.last end
field_definition()
click to toggle source
@return [GraphQL::Field, nil] The most-recently-entered GraphQL::Field
, if currently inside one
# File lib/graphql/static_validation/base_visitor.rb, line 170 def field_definition @field_definitions.last end
on_argument(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 119 def on_argument(node, parent) argument_defn = if (arg = @argument_definitions.last) arg_type = arg.type.unwrap if arg_type.kind.input_object? @context.warden.get_argument(arg_type, node.name) else nil end elsif (directive_defn = @directive_definitions.last) @context.warden.get_argument(directive_defn, node.name) elsif (field_defn = @field_definitions.last) @context.warden.get_argument(field_defn, node.name) else nil end @argument_definitions.push(argument_defn) @path.push(node.name) super @argument_definitions.pop @path.pop end
on_directive(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 112 def on_directive(node, parent) directive_defn = @context.schema_directives[node.name] @directive_definitions.push(directive_defn) super @directive_definitions.pop end
on_field(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 95 def on_field(node, parent) parent_type = @object_types.last field_definition = @schema.get_field(parent_type, node.name, @context.query.context) @field_definitions.push(field_definition) if !field_definition.nil? next_object_type = field_definition.type.unwrap push_type(next_object_type) else push_type(nil) end @path.push(node.alias || node.name) super @field_definitions.pop @object_types.pop @path.pop end
on_fragment_definition(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 81 def on_fragment_definition(node, parent) on_fragment_with_type(node) do @path.push("fragment #{node.name}") super end end
on_fragment_spread(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 142 def on_fragment_spread(node, parent) @path.push("... #{node.name}") super @path.pop end
on_inline_fragment(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 88 def on_inline_fragment(node, parent) on_fragment_with_type(node) do @path.push("...#{node.type ? " on #{node.type.to_query_string}" : ""}") super end end
on_input_object(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 148 def on_input_object(node, parent) arg_defn = @argument_definitions.last if arg_defn && arg_defn.type.list? @path.push(parent.children.index(node)) super @path.pop else super end end
on_operation_definition(node, parent)
click to toggle source
Calls superclass method
# File lib/graphql/static_validation/base_visitor.rb, line 72 def on_operation_definition(node, parent) object_type = @schema.root_type_for_operation(node.operation_type) push_type(object_type) @path.push("#{node.operation_type}#{node.name ? " #{node.name}" : ""}") super @object_types.pop @path.pop end
parent_type_definition()
click to toggle source
@return [GraphQL::BaseType] The type which the current type came from
# File lib/graphql/static_validation/base_visitor.rb, line 165 def parent_type_definition @object_types[-2] end
type_definition()
click to toggle source
@return [GraphQL::BaseType] The current object type
# File lib/graphql/static_validation/base_visitor.rb, line 160 def type_definition @object_types.last end
Private Instance Methods
on_fragment_with_type(node) { |node| ... }
click to toggle source
# File lib/graphql/static_validation/base_visitor.rb, line 188 def on_fragment_with_type(node) object_type = if node.type @context.warden.get_type(node.type.name) else @object_types.last end push_type(object_type) yield(node) @object_types.pop @path.pop end
push_type(t)
click to toggle source
# File lib/graphql/static_validation/base_visitor.rb, line 200 def push_type(t) @object_types.push(t) end