Sha256: be0ad792b9e642a4c14db81f9668a1772db19970afbb4d044f3e9876968f5064
Contents?: true
Size: 826 Bytes
Versions: 9
Compression:
Stored size: 826 Bytes
Contents
# frozen_string_literal: true module GraphqlRails module Model class BuildConnectionType # Used when generating ConnectionType. # It handles all the logic which is related with counting total items class CountItems require 'graphql_rails/concerns/service' include ::GraphqlRails::Service def initialize(graphql_object) @graphql_object = graphql_object end def call if active_record? list.except(:offset).size else list.size end end private attr_reader :graphql_object def list graphql_object.items end def active_record? defined?(ActiveRecord) && list.is_a?(ActiveRecord::Relation) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems