Sha256: b0250ad57289c9409547d1b077e2b8db4f2ebfe7e73f3508dbbeea0bdbee2984

Contents?: true

Size: 786 Bytes

Versions: 20

Compression:

Stored size: 786 Bytes

Contents

module GraphQL
  module Relay
    module ConnectionType
      # Create a connection which exposes edges of this type
      def self.create_type(wrapped_type, edge_type: nil, edge_class: nil, &block)
        edge_type ||= wrapped_type.edge_type
        edge_class ||= GraphQL::Relay::Edge
        connection_type_name = "#{wrapped_type.name}Connection"

        connection_type = ObjectType.define do
          name(connection_type_name)
          field :edges, types[edge_type] do
            resolve -> (obj, args, ctx) {
              obj.edge_nodes.map { |item| edge_class.new(item, obj) }
            }
          end
          field :pageInfo, !PageInfo, property: :page_info
          block && instance_eval(&block)
        end

        connection_type
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
graphql-0.19.2 lib/graphql/relay/connection_type.rb
graphql-0.19.1 lib/graphql/relay/connection_type.rb
graphql-0.19.0 lib/graphql/relay/connection_type.rb
graphql-0.18.15 lib/graphql/relay/connection_type.rb
graphql-0.18.14 lib/graphql/relay/connection_type.rb
graphql-0.18.13 lib/graphql/relay/connection_type.rb
graphql-0.18.12 lib/graphql/relay/connection_type.rb
graphql-0.18.11 lib/graphql/relay/connection_type.rb
graphql-0.18.10 lib/graphql/relay/connection_type.rb
graphql-0.18.9 lib/graphql/relay/connection_type.rb
graphql-0.18.8 lib/graphql/relay/connection_type.rb
graphql-0.18.7 lib/graphql/relay/connection_type.rb
graphql-0.18.6 lib/graphql/relay/connection_type.rb
graphql-0.18.5 lib/graphql/relay/connection_type.rb
graphql-0.18.4 lib/graphql/relay/connection_type.rb
graphql-0.18.3 lib/graphql/relay/connection_type.rb
graphql-0.18.2 lib/graphql/relay/connection_type.rb
graphql-0.18.1 lib/graphql/relay/connection_type.rb
graphql-0.18.0 lib/graphql/relay/connection_type.rb
graphql-relay-0.12.0 lib/graphql/relay/connection_type.rb