Class: GraphQL::Pagination::MongoidRelationConnection

Inherits:
RelationConnection show all
Defined in:
lib/graphql/pagination/mongoid_relation_connection.rb

Instance Attribute Summary

Attributes inherited from Connection

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

Instance Method Summary collapse

Methods inherited from RelationConnection

#cursor_for, #has_next_page, #has_previous_page, #nodes

Methods inherited from Connection

#after, #before, #cursor_for, #edge_nodes, #edges, #end_cursor, #has_max_page_size_override?, #has_next_page, #has_previous_page, #initialize, #max_page_size, #max_page_size=, #nodes, #page_info, #start_cursor

Constructor Details

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

Instance Method Details

#null_relation(relation) ⇒ Object


20
21
22
# File 'lib/graphql/pagination/mongoid_relation_connection.rb', line 20

def null_relation(relation)
  relation.without_options.none
end

#relation_count(relation) ⇒ Object


15
16
17
18
# File 'lib/graphql/pagination/mongoid_relation_connection.rb', line 15

def relation_count(relation)
  # Mongo's `.count` doesn't apply limit or skip, which we need. So we have to load _everything_!
  relation.to_a.count
end

#relation_limit(relation) ⇒ Object


11
12
13
# File 'lib/graphql/pagination/mongoid_relation_connection.rb', line 11

def relation_limit(relation)
  relation.options.limit
end

#relation_offset(relation) ⇒ Object


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

def relation_offset(relation)
  relation.options.skip
end