class GraphQL::Pagination::RelationConnection
A generic class for working with database query objects.
Public Instance Methods
Source
# File lib/graphql/pagination/relation_connection.rb, line 55 def cursor_for(item) load_nodes position = cursor_index_for(item, nodes) offset_cursor_for_position(position) end
Source
# File lib/graphql/pagination/relation_connection.rb, line 32 def has_next_page # If the query loads the page anyway, load it now so its extra row answers this if @has_next_page.nil? && peek_next_page? && (lookahead.selects?(:nodes) || lookahead.selects?(:edges) || page_info_selection.selects?(:start_cursor) || page_info_selection.selects?(:end_cursor)) load_nodes end if @has_next_page.nil? @has_next_page = if before_offset && before_offset > 0 true elsif first if @nodes && @nodes.count < first false else relation_larger_than(sliced_nodes, @sliced_nodes_offset, first) end else false end end @has_next_page end
Source
# File lib/graphql/pagination/relation_connection.rb, line 15 def has_previous_page if @has_previous_page.nil? @has_previous_page = if after_offset && after_offset > 0 true elsif last # See whether there are any nodes _before_ the current offset. # If there _is no_ current offset, then there can't be any nodes before it. # Assume that if the offset is positive, there are nodes before the offset. limited_nodes !(@paged_nodes_offset.nil? || @paged_nodes_offset == 0) else false end end @has_previous_page end
Source
# File lib/graphql/pagination/relation_connection.rb, line 10 def nodes load_nodes @nodes end