Class: GraphQL::Execution::Interpreter::Runtime::GraphQLResultArray
- Inherits:
-
Object
- Object
- GraphQL::Execution::Interpreter::Runtime::GraphQLResultArray
show all
- Includes:
- GraphQLResult
- Defined in:
- lib/graphql/execution/interpreter/runtime/graphql_result.rb
Instance Attribute Summary
#ast_node, #base_path, #graphql_application_value, #graphql_arguments, #graphql_dead, #graphql_field, #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
-
#[](idx) ⇒ Object
-
#graphql_skip_at(index) ⇒ Object
-
#initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager, _ast_node, _graphql_arguments, graphql_field) ⇒ GraphQLResultArray
constructor
rubocop:disable Metrics/ParameterLists.
-
#set_child_result(idx, value) ⇒ Object
-
#set_leaf(idx, value) ⇒ Object
-
#values ⇒ Object
#build_path, #depth, #path
Constructor Details
#initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager, _ast_node, _graphql_arguments, graphql_field) ⇒ GraphQLResultArray
rubocop:disable Metrics/ParameterLists
182
183
184
185
|
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 182
def initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager, _ast_node, _graphql_arguments, graphql_field) super
@graphql_result_data = []
end
|
Instance Method Details
#[](idx) ⇒ Object
225
226
227
|
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 225
def [](idx)
(@graphql_metadata || @graphql_result_data)[idx]
end
|
#graphql_skip_at(index) ⇒ Object
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 187
def graphql_skip_at(index)
@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
209
210
211
212
213
214
215
216
217
218
219
|
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 209
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
(@graphql_metadata ||= @graphql_result_data.dup)[idx] = value
value
end
|
#set_leaf(idx, value) ⇒ Object
199
200
201
202
203
204
205
206
207
|
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 199
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
221
222
223
|
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 221
def values
(@graphql_metadata || @graphql_result_data)
end
|