Method: GraphQL::Relay::BaseConnection#initialize

Defined in:
lib/graphql/relay/base_connection.rb

#initialize(nodes, arguments, field: nil, max_page_size: nil, parent: nil, context: nil) ⇒ BaseConnection

Make a connection, wrapping nodes

Parameters:

  • nodes (Object)

    The collection of nodes

  • arguments (GraphQL::Query::Arguments)

    Query arguments

  • field (GraphQL::Field) (defaults to: nil)

    The underlying field

  • max_page_size (Int) (defaults to: nil)

    The maximum number of results to return

  • parent (Object) (defaults to: nil)

    The object which this collection belongs to

  • context (GraphQL::Query::Context) (defaults to: nil)

    The context from the field being resolved



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/graphql/relay/base_connection.rb', line 61

def initialize(nodes, arguments, field: nil, max_page_size: nil, parent: nil, context: nil)
  GraphQL::Deprecation.warn "GraphQL::Relay::BaseConnection (used for #{self.class}) will be removed from GraphQL-Ruby 2.0, use GraphQL::Pagination::Connections instead: https://graphql-ruby.org/pagination/overview.html"

  deprecated_caller = caller(0, 10).find { |c| !c.include?("lib/graphql") }
  if deprecated_caller
    GraphQL::Deprecation.warn "  -> called from #{deprecated_caller}"
  end

  @context = context
  @nodes = nodes
  @arguments = arguments
  @field = field
  @parent = parent
  @encoder = context ? @context.schema.cursor_encoder : GraphQL::Schema::Base64Encoder
  @max_page_size = max_page_size.nil? && context ? @context.schema.default_max_page_size : max_page_size
end