Sha256: 07a4d7501e1917cd623a92e6c46ba2f638527f9e5c77a64e144e64b66f4d09a9

Contents?: true

Size: 1.6 KB

Versions: 36

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true
module GraphQL
  module Relay
    # @api deprecated
    module ConnectionType
      class << self
        # @return [Boolean] If true, connection types get a `nodes` shortcut field
        attr_accessor :default_nodes_field
        # @return [Boolean] If true, connections check for reverse-direction `has*Page` values
        attr_accessor :bidirectional_pagination
      end

      self.default_nodes_field = false
      self.bidirectional_pagination = false

      # @api deprecated
      def self.create_type(wrapped_type, edge_type: nil, edge_class: GraphQL::Relay::Edge, nodes_field: ConnectionType.default_nodes_field, &block)
        custom_edge_class = edge_class

        # Any call that would trigger `wrapped_type.ensure_defined`
        # must be inside this lazy block, otherwise we get weird
        # cyclical dependency errors :S
        ObjectType.deprecated_define do
          type_name = wrapped_type.is_a?(GraphQL::BaseType) ? wrapped_type.name : wrapped_type.graphql_name
          edge_type ||= wrapped_type.edge_type
          name("#{type_name}Connection")
          description("The connection type for #{type_name}.")
          field :edges, types[edge_type], "A list of edges.", edge_class: custom_edge_class, property: :edge_nodes

          if nodes_field
            field :nodes, types[wrapped_type],  "A list of nodes.", property: :edge_nodes
          end

          field :pageInfo, !PageInfo, "Information to aid in pagination.", property: :page_info
          relay_node_type(wrapped_type)
          block && instance_eval(&block)
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
graphql-1.12.15 lib/graphql/relay/connection_type.rb
graphql-1.12.14 lib/graphql/relay/connection_type.rb
graphql-1.12.13 lib/graphql/relay/connection_type.rb
graphql-1.12.12 lib/graphql/relay/connection_type.rb
graphql-1.12.11 lib/graphql/relay/connection_type.rb
graphql-1.12.10 lib/graphql/relay/connection_type.rb
graphql-1.12.9 lib/graphql/relay/connection_type.rb
graphql-1.12.8 lib/graphql/relay/connection_type.rb
graphql-1.12.7 lib/graphql/relay/connection_type.rb
graphql-1.12.6 lib/graphql/relay/connection_type.rb
graphql-1.12.5 lib/graphql/relay/connection_type.rb
graphql-1.12.4 lib/graphql/relay/connection_type.rb
graphql-1.12.3 lib/graphql/relay/connection_type.rb
graphql-1.12.2 lib/graphql/relay/connection_type.rb
graphql-1.12.1 lib/graphql/relay/connection_type.rb
graphql-1.12.0 lib/graphql/relay/connection_type.rb