@@ -12,6 +12,8 @@ def self.included(child_class)
12
12
child_class . extend ( Relay ::DefaultRelay )
13
13
child_class . default_relay ( true )
14
14
child_class . node_nullable ( true )
15
+ child_class . edges_nullable ( true )
16
+ child_class . edge_nullable ( true )
15
17
add_page_info_field ( child_class )
16
18
end
17
19
@@ -32,16 +34,16 @@ module ClassMethods
32
34
# It's called when you subclass this base connection, trying to use the
33
35
# class name to set defaults. You can call it again in the class definition
34
36
# to override the default (or provide a value, if the default lookup failed).
35
- def edge_type ( edge_type_class , edge_class : GraphQL ::Relay ::Edge , node_type : edge_type_class . node_type , nodes_field : true , node_nullable : self . node_nullable )
37
+ def edge_type ( edge_type_class , edge_class : GraphQL ::Relay ::Edge , node_type : edge_type_class . node_type , nodes_field : true , node_nullable : self . node_nullable , edges_nullable : self . edges_nullable , edge_nullable : self . edge_nullable )
36
38
# Set this connection's graphql name
37
39
node_type_name = node_type . graphql_name
38
40
39
41
@node_type = node_type
40
42
@edge_type = edge_type_class
41
43
@edge_class = edge_class
42
44
43
- field :edges , [ edge_type_class , null : true ] ,
44
- null : true ,
45
+ field :edges , [ edge_type_class , null : edge_nullable ] ,
46
+ null : edges_nullable ,
45
47
description : "A list of edges." ,
46
48
legacy_edge_class : edge_class , # This is used by the old runtime only, for EdgesInstrumentation
47
49
connection : false
@@ -83,6 +85,26 @@ def node_nullable(new_value = nil)
83
85
end
84
86
end
85
87
88
+ # Set the default `edges_nullable` for this class and its child classes. (Defaults to `true`.)
89
+ # Use `edges_nullable(false)` in your base class to make non-null `edges` fields.
90
+ def edges_nullable ( new_value = nil )
91
+ if new_value . nil?
92
+ @edges_nullable || superclass . edges_nullable
93
+ else
94
+ @edges_nullable ||= new_value
95
+ end
96
+ end
97
+
98
+ # Set the default `edge_nullable` for this class and its child classes. (Defaults to `true`.)
99
+ # Use `edge_nullable(false)` in your base class to make non-null `edge` fields.
100
+ def edge_nullable ( new_value = nil )
101
+ if new_value . nil?
102
+ @edge_nullable || superclass . edge_nullable
103
+ else
104
+ @edge_nullable ||= new_value
105
+ end
106
+ end
107
+
86
108
private
87
109
88
110
def define_nodes_field ( nullable )
0 commit comments