Class: GraphQL::Execution::Interpreter::Runtime::GraphQLResultHash Private
- Inherits:
- 
      Object
      
        - Object
- GraphQL::Execution::Interpreter::Runtime::GraphQLResultHash
 
- Includes:
- GraphQLResult
- Defined in:
- lib/graphql/execution/interpreter/runtime/graphql_result.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- 
  
    
      #graphql_merged_into  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  private
  
    
Attributes included from GraphQLResult
#graphql_application_value, #graphql_dead, #graphql_is_eager, #graphql_is_non_null_in_parent, #graphql_parent, #graphql_result_data, #graphql_result_name, #graphql_result_type, #graphql_selections
Instance Method Summary collapse
- 
  
    
      #[](k)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #delete(key)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #each  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager)  ⇒ GraphQLResultHash 
    
    
  
  
  
    constructor
  
  
  
  
  
  private
  
    A new instance of GraphQLResultHash. 
- 
  
    
      #key?(k)  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #merge_into(into_result)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #set_child_result(key, value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #set_leaf(key, value)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
- 
  
    
      #values  ⇒ Object 
    
    
  
  
  
  
  
  
  
  private
  
    
Methods included from GraphQLResult
Constructor Details
#initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager) ⇒ GraphQLResultHash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of GraphQLResultHash.
| 41 42 43 44 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 41 def initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager) super @graphql_result_data = {} end | 
Instance Attribute Details
#graphql_merged_into ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 48 49 50 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 48 def graphql_merged_into @graphql_merged_into end | 
Instance Method Details
#[](k) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 98 99 100 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 98 def [](k) (@graphql_metadata || @graphql_result_data)[k] end | 
#delete(key) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 81 82 83 84 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 81 def delete(key) @graphql_metadata && @graphql_metadata.delete(key) @graphql_result_data.delete(key) end | 
#each ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 86 87 88 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 86 def each (@graphql_metadata || @graphql_result_data).each { |k, v| yield(k, v) } end | 
#key?(k) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 94 95 96 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 94 def key?(k) @graphql_result_data.key?(k) end | 
#merge_into(into_result) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 102 def merge_into(into_result) self.each do |key, value| case value when GraphQLResultHash next_into = into_result[key] if next_into value.merge_into(next_into) else into_result.set_child_result(key, value) end when GraphQLResultArray # There's no special handling of arrays because currently, there's no way to split the execution # of a list over several concurrent flows. into_result.set_child_result(key, value) else # We have to assume that, since this passed the `fields_will_merge` selection, # that the old and new values are the same. into_result.set_leaf(key, value) end end @graphql_merged_into = into_result end | 
#set_child_result(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 70 71 72 73 74 75 76 77 78 79 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 70 def set_child_result(key, value) if (t = @graphql_merged_into) t.set_child_result(key, value) end @graphql_result_data[key] = value.graphql_result_data # If we encounter some part of this response that requires metadata tracking, # then create the metadata hash if necessary. It will be kept up-to-date after this. (@graphql_metadata ||= @graphql_result_data.dup)[key] = value value end | 
#set_leaf(key, value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 50 def set_leaf(key, value) # This is a hack. # Basically, this object is merged into the root-level result at some point. # But the problem is, some lazies are created whose closures retain reference to _this_ # object. When those lazies are resolved, they cause an update to this object. # # In order to return a proper top-level result, we have to update that top-level result object. # In order to return a proper partial result (eg, for a directive), we have to update this object, too. # Yowza. if (t = @graphql_merged_into) t.set_leaf(key, value) end @graphql_result_data[key] = value # keep this up-to-date if it's been initialized @graphql_metadata && @graphql_metadata[key] = value value end | 
#values ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
| 90 91 92 | # File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 90 def values (@graphql_metadata || @graphql_result_data).values end |