Module: GraphQL::Relay::TypeExtensions

Included in:
BaseType, Schema::Interface::DefinitionMethods, Schema::Member
Defined in:
lib/graphql/relay/type_extensions.rb

Overview

Mixin for Relay-related methods in type objects (used by BaseType and Schema::Member).

Instance Method Summary collapse

Instance Method Details

#connection_typeGraphQL::ObjectType

Returns The default connection type for this object type.

Returns:



8
9
10
# File 'lib/graphql/relay/type_extensions.rb', line 8

def connection_type
  @connection_type ||= define_connection
end

#define_connection(**kwargs, &block) ⇒ GraphQL::ObjectType

Define a custom connection type for this object type

Returns:



14
15
16
17
# File 'lib/graphql/relay/type_extensions.rb', line 14

def define_connection(**kwargs, &block)
  GraphQL::Deprecation.warn ".connection_type and .define_connection will be removed from GraphQL-Ruby 2.0, use class-based type definitions instead: https://graphql-ruby.org/schema/class_based_api.html"
  GraphQL::Relay::ConnectionType.create_type(self, **kwargs, &block)
end

#define_edge(**kwargs, &block) ⇒ GraphQL::ObjectType

Define a custom edge type for this object type

Returns:



26
27
28
29
# File 'lib/graphql/relay/type_extensions.rb', line 26

def define_edge(**kwargs, &block)
  GraphQL::Deprecation.warn ".edge_type and .define_edge will be removed from GraphQL-Ruby 2.0, use class-based type definitions instead: https://graphql-ruby.org/schema/class_based_api.html"
  GraphQL::Relay::EdgeType.create_type(self, **kwargs, &block)
end

#edge_typeGraphQL::ObjectType

Returns The default edge type for this object type.

Returns:



20
21
22
# File 'lib/graphql/relay/type_extensions.rb', line 20

def edge_type
  @edge_type ||= define_edge
end