Class: GraphQL::Relay::ArrayConnection
  
  
  
  Constant Summary
  
  
  BaseConnection::CONNECTION_IMPLEMENTATIONS, BaseConnection::CURSOR_SEPARATOR
  Instance Attribute Summary
  
  
  #arguments, #context, #field, #max_page_size, #nodes, #parent
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #after, #before, connection_for_nodes, #decode, #edge_nodes, #encode, #end_cursor, #initialize, #inspect, #page_info, register_connection_implementation, #start_cursor
  
    Instance Method Details
    
      
  
  
    #cursor_from_node(item)  ⇒ Object 
  
  
  
  
    | 
5
6
7
8 | # File 'lib/graphql/relay/array_connection.rb', line 5
def cursor_from_node(item)
  idx = (after ? index_from_cursor(after) : 0) + sliced_nodes.find_index(item) + 1
  encode(idx.to_s)
end | 
 
    
      
  
  
    #first  ⇒ Object 
  
  
  
  
    | 
34
35
36
37
38
39
40
41
42 | # File 'lib/graphql/relay/array_connection.rb', line 34
def first
  @first ||= begin
    capped = (arguments[:first], max_page_size)
    if capped.nil? && last.nil?
      capped = max_page_size
    end
    capped
  end
end | 
 
    
      
  
  
    #has_next_page  ⇒ Object 
  
  
  
  
    | 
10
11
12
13
14
15
16
17
18
19
20 | # File 'lib/graphql/relay/array_connection.rb', line 10
def has_next_page
  if first
        sliced_nodes.count > first
  elsif GraphQL::Relay::ConnectionType. && before
        index_from_cursor(before) < nodes.length + 1
  else
    false
  end
end | 
 
    
      
  
  
    #has_previous_page  ⇒ Object 
  
  
  
  
    | 
22
23
24
25
26
27
28
29
30
31
32 | # File 'lib/graphql/relay/array_connection.rb', line 22
def has_previous_page
  if last
        sliced_nodes.count > last
  elsif GraphQL::Relay::ConnectionType. && after
        index_from_cursor(after) > 0
  else
    false
  end
end | 
 
    
      
  
  
    #last  ⇒ Object 
  
  
  
  
    | 
44
45
46 | # File 'lib/graphql/relay/array_connection.rb', line 44
def last
  @last ||= (arguments[:last], max_page_size)
end |