Class: GraphQL::Execution::Interpreter::Runtime::GraphQLResultArray Private

Inherits:
Object
  • Object
show all
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

Attributes included from GraphQLResult

#ast_node, #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

Methods included from GraphQLResult

#build_path, #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

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.

rubocop:disable Metrics/ParameterLists



132
133
134
135
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 132

def initialize(_result_name, _result_type, _application_value, _parent_result, _is_non_null_in_parent, _selections, _is_eager, _ast_node, _graphql_arguments, graphql_field) # rubocop:disable Metrics/ParameterLists
  super
  @graphql_result_data = []
end

Instance Method Details

#[](idx) ⇒ 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
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 175

def [](idx)
  (@graphql_metadata || @graphql_result_data)[idx]
end

#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.



137
138
139
140
141
142
143
144
145
146
147
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 137

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.



159
160
161
162
163
164
165
166
167
168
169
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 159

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.



149
150
151
152
153
154
155
156
157
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 149

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

#valuesObject

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.



171
172
173
# File 'lib/graphql/execution/interpreter/runtime/graphql_result.rb', line 171

def values
  (@graphql_metadata || @graphql_result_data)
end