6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/graphql_includable/relay/edge_with_node_connection_type.rb', line 6
def self.create_type(
wrapped_type,
edge_type: wrapped_type.edge_type, edge_class: EdgeWithNode,
nodes_field: GraphQL::Relay::ConnectionType.default_nodes_field, &block
)
custom_edge_class = edge_class
GraphQL::ObjectType.define do
name("#{wrapped_type.name}Connection")
description("The connection type for #{wrapped_type.name}.")
field :totalCount, types.Int, 'Total count.', property: :total_count
field :edges, types[edge_type], 'A list of edges.' do
edge_class custom_edge_class
property :fetch_edges
_includable_connection_marker true
end
if nodes_field
field :nodes, types[wrapped_type], 'A list of nodes.', property: :fetch_nodes
end
field :pageInfo, !GraphQL::Relay::PageInfo, 'Information to aid in pagination.', property: :page_info
block && instance_eval(&block)
end
end
|