Module: GraphqlPagination::CollectionType

Defined in:
lib/graphql_pagination/collection_type.rb

Instance Method Summary collapse

Instance Method Details

#collection_type(metadata_type: GraphqlPagination::CollectionMetadataType) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/graphql_pagination/collection_type.rb', line 3

def collection_type(metadata_type: GraphqlPagination::CollectionMetadataType)
  @collection_types ||= {}
  @collection_types[] ||= 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, , null: false

      def collection
        object
      end

      def 
        object
      end
    end
  end
end