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

#initializeGraphQLResultArray

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.



89
90
91
92
93
94
# File 'lib/graphql/execution/interpreter/runtime.rb', line 89

def initialize
  # Avoid this duplicate allocation if possible -
  # but it will require some work to keep it up-to-date if it's created.
  @graphql_metadata = nil
  @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.



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/graphql/execution/interpreter/runtime.rb', line 108

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.



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/graphql/execution/interpreter/runtime.rb', line 96

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.



124
125
126
# File 'lib/graphql/execution/interpreter/runtime.rb', line 124

def values
  (@graphql_metadata || @graphql_result_data)
end