Sha256: e90d30956e7d8705c821062d0740137cb9492057930d29a404be87a583b13caf

Contents?: true

Size: 632 Bytes

Versions: 6

Compression:

Stored size: 632 Bytes

Contents

module GraphqlPagination
  module CollectionType
    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graphql-pagination-2.0.1 lib/graphql_pagination/collection_type.rb
graphql-pagination-2.0.0 lib/graphql_pagination/collection_type.rb
graphql-pagination-2.0.0.rc lib/graphql_pagination/collection_type.rb
graphql-pagination-1.2.1 lib/graphql_pagination/collection_type.rb
graphql-pagination-1.2.0 lib/graphql_pagination/collection_type.rb
graphql-pagination-1.1.3 lib/graphql_pagination/collection_type.rb