class GraphQL::Analysis::QueryComplexity::TypeComplexity
Selections on an object may apply differently depending on what is actually returned by the resolve function. Find the maximum possible complexity among those combinations.
Public Class Methods
new()
click to toggle source
# File lib/graphql/analysis/query_complexity.rb, line 71 def initialize @types = Hash.new(0) end
Public Instance Methods
max_possible_complexity()
click to toggle source
Return the max possible complexity for types in this selection
# File lib/graphql/analysis/query_complexity.rb, line 76 def max_possible_complexity @types.each_value.max || 0 end
merge(type_defn, complexity)
click to toggle source
Store the complexity for the branch on `type_defn`. Later we will see if this is the max complexity among branches.
# File lib/graphql/analysis/query_complexity.rb, line 82 def merge(type_defn, complexity) @types[type_defn] += complexity end