Skip to content

Instantly share code, notes, and snippets.

@msroot
Last active April 28, 2020 13:13
Show Gist options
  • Save msroot/a51c9ead613f0969607b15b8abd285d8 to your computer and use it in GitHub Desktop.
Save msroot/a51c9ead613f0969607b15b8abd285d8 to your computer and use it in GitHub Desktop.
add total_count to all connections
class Types::BaseConnection < GraphQL::Types::Relay::BaseConnection
field :total_count, Integer, null: false
def total_count
object.items.size
end
end
module Types
class BaseObject < GraphQL::Schema::Object
connection_type_class Types::BaseConnection
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment