Class: GraphQL::Execution::Interpreter::Runtime::GraphQLResultHash Private
- Inherits:
-
Object
- Object
- GraphQL::Execution::Interpreter::Runtime::GraphQLResultHash
- Includes:
- GraphQLResult
- Defined in:
- lib/graphql/execution/interpreter/runtime.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_dead, #graphql_non_null_field_names, #graphql_non_null_list_items, #graphql_parent, #graphql_result_data, #graphql_result_name
Instance Method Summary collapse
-
#[](k) ⇒ Object
private
-
#[]=(key, value) ⇒ Object
private
-
#delete(key) ⇒ Object
private
-
#each ⇒ Object
private
-
#initialize ⇒ GraphQLResultHash
constructor
private
A new instance of GraphQLResultHash.
-
#key?(k) ⇒ Boolean
private
-
#values ⇒ Object
private
Constructor Details
#initialize ⇒ 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.
27 28 29 30 31 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 27 def initialize # Jump through some hoops to avoid creating this duplicate hash if at all possible. @graphql_metadata = nil @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.
35 36 37 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 35 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.
81 82 83 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 81 def [](k) (@graphql_metadata || @graphql_result_data)[k] end |
#[]=(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.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 37 def []=(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[key] = value end if value.respond_to?(:graphql_result_data) @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 else @graphql_result_data[key] = value # keep this up-to-date if it's been initialized @graphql_metadata && @graphql_metadata[key] = value end value 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.
64 65 66 67 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 64 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.
69 70 71 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 69 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.
77 78 79 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 77 def key?(k) @graphql_result_data.key?(k) 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.
73 74 75 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 73 def values (@graphql_metadata || @graphql_result_data).values end |