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, #first, #first_value, #items, #last, #last_value, #max_page_size

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_class, #edge_nodes, #edges, #end_cursor, #has_next_page, #has_previous_page, #initialize, #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