Class: GraphQL::Pagination::ArrayConnection

Inherits:
Connection
  • Object
show all
Defined in:
lib/graphql/pagination/array_connection.rb

Instance Attribute Summary

Attributes inherited from Connection

#after_value, #arguments, #before_value, #context, #edge_class, #field, #first, #first_value, #items, #last, #last_value, #parent

Instance Method Summary collapse

Methods inherited from Connection

#after, #before, #edge_nodes, #edges, #end_cursor, #has_max_page_size_override?, #initialize, #max_page_size, #max_page_size=, #page_info, #range_add_edge, #start_cursor

Constructor Details

This class inherits a constructor from GraphQL::Pagination::Connection

Instance Method Details

#cursor_for(item) ⇒ Object



22
23
24
25
# File 'lib/graphql/pagination/array_connection.rb', line 22

def cursor_for(item)
  idx = items.find_index(item) + 1
  encode(idx.to_s)
end

#has_next_pageObject



17
18
19
20
# File 'lib/graphql/pagination/array_connection.rb', line 17

def has_next_page
  load_nodes
  @has_next_page
end

#has_previous_pageObject



12
13
14
15
# File 'lib/graphql/pagination/array_connection.rb', line 12

def has_previous_page
  load_nodes
  @has_previous_page
end

#nodesObject



7
8
9
10
# File 'lib/graphql/pagination/array_connection.rb', line 7

def nodes
  load_nodes
  @nodes
end