Last active
April 28, 2020 13:13
-
-
Save msroot/a51c9ead613f0969607b15b8abd285d8 to your computer and use it in GitHub Desktop.
add total_count to all connections
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Types::BaseConnection < GraphQL::Types::Relay::BaseConnection | |
field :total_count, Integer, null: false | |
def total_count | |
object.items.size | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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