Class: GraphqlRails::Model::BuildConnectionType::CountItems

Inherits:
Object
  • Object
show all
Includes:
Service
Defined in:
lib/graphql_rails/model/build_connection_type/count_items.rb

Overview

Used when generating ConnectionType. It handles all the logic which is related with counting total items

Instance Method Summary collapse

Constructor Details

#initialize(graphql_object) ⇒ CountItems

Returns a new instance of CountItems.



13
14
15
# File 'lib/graphql_rails/model/build_connection_type/count_items.rb', line 13

def initialize(graphql_object)
  @graphql_object = graphql_object
end

Instance Method Details

#callObject



17
18
19
20
21
22
23
# File 'lib/graphql_rails/model/build_connection_type/count_items.rb', line 17

def call
  if active_record?
    list.except(:offset).size
  else
    list.size
  end
end