Class: GraphQL::Execution::Interpreter::Runtime::GraphQLResultArray Private
- Inherits:
-
Object
- Object
- GraphQL::Execution::Interpreter::Runtime::GraphQLResultArray
- 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
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
-
#graphql_skip_at(index) ⇒ Object
private
-
#initialize(_result_name, _parent_result) ⇒ GraphQLResultArray
constructor
private
A new instance of GraphQLResultArray.
-
#set_child_result(idx, value) ⇒ Object
private
-
#set_leaf(idx, value) ⇒ Object
private
-
#values ⇒ Object
private
Methods included from GraphQLResult
Constructor Details
#initialize(_result_name, _parent_result) ⇒ GraphQLResultArray
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 GraphQLResultArray.
148 149 150 151 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 148 def initialize(_result_name, _parent_result) super @graphql_result_data = [] end |
Instance Method Details
#graphql_skip_at(index) ⇒ 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.
153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 153 def graphql_skip_at(index) # Mark this index as dead. It's tricky because some indices may already be storing # `Lazy`s. So the runtime is still holding indexes _before_ skipping, # this object has to coordinate incoming writes to account for any already-skipped indices. @skip_indices ||= [] @skip_indices << index offset_by = @skip_indices.count { |skipped_idx| skipped_idx < index} delete_at_index = index - offset_by @graphql_metadata && @graphql_metadata.delete_at(delete_at_index) @graphql_result_data.delete_at(delete_at_index) end |
#set_child_result(idx, 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.
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 175 def set_child_result(idx, value) if @skip_indices offset_by = @skip_indices.count { |skipped_idx| skipped_idx < idx } idx -= offset_by end @graphql_result_data[idx] = 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)[idx] = value value end |
#set_leaf(idx, 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.
165 166 167 168 169 170 171 172 173 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 165 def set_leaf(idx, value) if @skip_indices offset_by = @skip_indices.count { |skipped_idx| skipped_idx < idx } idx -= offset_by end @graphql_result_data[idx] = value @graphql_metadata && @graphql_metadata[idx] = 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.
187 188 189 |
# File 'lib/graphql/execution/interpreter/runtime.rb', line 187 def values (@graphql_metadata || @graphql_result_data) end |