module GraphqlPagination::CollectionType

Public Instance Methods

collection() click to toggle source
# File lib/graphql_pagination/collection_type.rb, line 14
def collection
  object
end
collection_type(metadata_type: GraphqlPagination::CollectionMetadataType) click to toggle source
# File lib/graphql_pagination/collection_type.rb, line 3
def collection_type(metadata_type: GraphqlPagination::CollectionMetadataType)
  @collection_types ||= {}
  @collection_types[metadata_type] ||= begin
    type_name = "#{graphql_name}Collection"
    source_type = self

    Class.new(GraphQL::Schema::Object) do
      graphql_name type_name
      field :collection, [source_type], null: false
      field :metadata, metadata_type, null: false

      def collection
        object
      end

      def metadata
        object
      end
    end
  end
end
metadata() click to toggle source
# File lib/graphql_pagination/collection_type.rb, line 18
def metadata
  object
end