Class: GraphQL::Analysis::QueryComplexity::ScopedTypeComplexity
- Inherits:
 - 
      Hash
      
        
- Object
 - Hash
 - GraphQL::Analysis::QueryComplexity::ScopedTypeComplexity
 
 
- Defined in:
 - lib/graphql/analysis/query_complexity.rb
 
Overview
ScopedTypeComplexity models a tree of GraphQL types mapped to inner selections, ie: Hash<GraphQL::BaseType, Hash<String, ScopedTypeComplexity»
Constant Summary collapse
- DEFAULT_PROC =
          
A proc for defaulting empty namespace requests as a new scope hash.
 ->(h, k) { h[k] = {} }
Instance Attribute Summary collapse
- 
  
    
      #field_definition  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute field_definition.
 - 
  
    
      #nodes  ⇒ Array<GraphQL::Language::Nodes::Field> 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
 - 
  
    
      #query  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute query.
 - 
  
    
      #response_path  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    
Returns the value of attribute response_path.
 
Instance Method Summary collapse
- 
  
    
      #composite?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    
 - 
  
    
      #initialize(parent_type, field_definition, query, response_path)  ⇒ Hash<GraphQL::BaseType, Hash<String, ScopedTypeComplexity>> 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
 - 
  
    
      #own_complexity(child_complexity)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
 
Constructor Details
#initialize(parent_type, field_definition, query, response_path) ⇒ Hash<GraphQL::BaseType, Hash<String, ScopedTypeComplexity>>
      57 58 59 60 61 62 63 64  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 57 def initialize(parent_type, field_definition, query, response_path) super(&DEFAULT_PROC) @parent_type = parent_type @field_definition = field_definition @query = query @response_path = response_path @nodes = [] end  | 
  
Instance Attribute Details
#field_definition ⇒ Object (readonly)
Returns the value of attribute field_definition.
      50 51 52  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 50 def field_definition @field_definition end  | 
  
#nodes ⇒ Array<GraphQL::Language::Nodes::Field> (readonly)
      67 68 69  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 67 def nodes @nodes end  | 
  
#query ⇒ Object (readonly)
Returns the value of attribute query.
      50 51 52  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 50 def query @query end  | 
  
#response_path ⇒ Object (readonly)
Returns the value of attribute response_path.
      50 51 52  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 50 def response_path @response_path end  | 
  
Instance Method Details
#composite? ⇒ Boolean
      73 74 75  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 73 def composite? !empty? end  | 
  
#own_complexity(child_complexity) ⇒ Object
      69 70 71  | 
    
      # File 'lib/graphql/analysis/query_complexity.rb', line 69 def own_complexity(child_complexity) @field_definition.calculate_complexity(query: @query, nodes: @nodes, child_complexity: child_complexity) end  |