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

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

Methods included from GraphQLResult

#build_path, #path

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.



109
110
111
112
# File 'lib/graphql/execution/interpreter/runtime.rb', line 109

def initialize(_result_name, _parent_result)
  super
  @graphql_result_data = []
end

Instance Method Details

#[]=(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.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/graphql/execution/interpreter/runtime.rb', line 126

def []=(idx, value)
  if @skip_indices
    offset_by = @skip_indices.count { |skipped_idx| skipped_idx < idx }
    idx -= offset_by
  end
  if value.respond_to?(:graphql_result_data)
    @graphql_result_data[idx] = value.graphql_result_data
    (@graphql_metadata ||= @graphql_result_data.dup)[idx] = value
  else
    @graphql_result_data[idx] = value
    @graphql_metadata && @graphql_metadata[idx] = value
  end

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



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/graphql/execution/interpreter/runtime.rb', line 114

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

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



142
143
144
# File 'lib/graphql/execution/interpreter/runtime.rb', line 142

def values
  (@graphql_metadata || @graphql_result_data)
end