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

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.



100
101
102
103
# File 'lib/graphql/execution/interpreter/runtime.rb', line 100

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.



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/graphql/execution/interpreter/runtime.rb', line 117

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.



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/graphql/execution/interpreter/runtime.rb', line 105

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.



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

def values
  (@graphql_metadata || @graphql_result_data)
end