class GraphQL::Analysis::AST::QueryDepth
Public Class Methods
new(query)
click to toggle source
Calls superclass method
GraphQL::Analysis::AST::Analyzer::new
# File lib/graphql/analysis/ast/query_depth.rb, line 29 def initialize(query) @max_depth = 0 @current_depth = 0 super end
Public Instance Methods
on_enter_field(node, parent, visitor)
click to toggle source
# File lib/graphql/analysis/ast/query_depth.rb, line 35 def on_enter_field(node, parent, visitor) return if visitor.skipping? || visitor.visiting_fragment_definition? @current_depth += 1 end
on_leave_field(node, parent, visitor)
click to toggle source
# File lib/graphql/analysis/ast/query_depth.rb, line 41 def on_leave_field(node, parent, visitor) return if visitor.skipping? || visitor.visiting_fragment_definition? if @max_depth < @current_depth @max_depth = @current_depth end @current_depth -= 1 end
result()
click to toggle source
# File lib/graphql/analysis/ast/query_depth.rb, line 50 def result @max_depth end