Module: GraphQL::Relay::ConnectionType
- Defined in:
- lib/graphql/relay/connection_type.rb
Class Attribute Summary collapse
-
.bidirectional_pagination ⇒ Boolean
If true, connections check for reverse-direction
has*Page
values. -
.default_nodes_field ⇒ Boolean
If true, connection types get a
nodes
shortcut field.
Class Method Summary collapse
-
.create_type(wrapped_type, edge_type: nil, edge_class: GraphQL::Relay::Edge, nodes_field: ConnectionType.default_nodes_field, &block) ⇒ Object
Create a connection which exposes edges of this type.
Class Attribute Details
.bidirectional_pagination ⇒ Boolean
Returns If true, connections check for reverse-direction has*Page
values
9 10 11 |
# File 'lib/graphql/relay/connection_type.rb', line 9 def bidirectional_pagination @bidirectional_pagination end |
.default_nodes_field ⇒ Boolean
Returns If true, connection types get a nodes
shortcut field
7 8 9 |
# File 'lib/graphql/relay/connection_type.rb', line 7 def default_nodes_field @default_nodes_field end |
Class Method Details
.create_type(wrapped_type, edge_type: nil, edge_class: GraphQL::Relay::Edge, nodes_field: ConnectionType.default_nodes_field, &block) ⇒ Object
Create a connection which exposes edges of this type
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/graphql/relay/connection_type.rb', line 16 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.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 |