Class: Types::LimitedCountableConnectionType

Inherits:
GraphQL::Types::Relay::BaseConnection
  • Object
show all
Defined in:
app/graphql/types/limited_countable_connection_type.rb

Overview

rubocop: disable Graphql/AuthorizeTypes

Constant Summary collapse

COUNT_LIMIT =
1000
COUNT_DESCRIPTION =
"Limited count of collection. Returns limit + 1 for counts greater than the limit."

Instance Method Summary collapse

Instance Method Details

#count(limit:) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'app/graphql/types/limited_countable_connection_type.rb', line 16

def count(limit:)
  relation = object.items

  if relation.respond_to?(:page)
    relation.page.total_count_with_limit(:all, limit: limit)
  else
    [relation.size, limit.next].min
  end
end