Skip to content

Commit abff3d7

Browse files
minhtuleekampf
authored andcommitted
Allow the connection node to be wrapped in a NonNull type (#934)
1 parent daf0d17 commit abff3d7

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

graphene/relay/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Meta:
5353
def __init_subclass_with_meta__(cls, node=None, name=None, **options):
5454
_meta = ConnectionOptions(cls)
5555
assert node, "You have to provide a node in {}.Meta".format(cls.__name__)
56-
assert issubclass(
56+
assert isinstance(node, NonNull) or issubclass(
5757
node, (Scalar, Enum, ObjectType, Interface, Union, NonNull)
5858
), ('Received incompatible node "{}" for Connection {}.').format(
5959
node, cls.__name__

graphene/relay/tests/test_connection.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ class Edge(BaseEdge):
108108
assert edge_fields["other"].type == String
109109

110110

111+
def test_edge_with_nonnull_node():
112+
class MyObjectConnection(Connection):
113+
class Meta:
114+
node = NonNull(MyObject)
115+
116+
edge_fields = MyObjectConnection.Edge._meta.fields
117+
assert isinstance(edge_fields["node"], Field)
118+
assert isinstance(edge_fields["node"].type, NonNull)
119+
assert edge_fields["node"].type.of_type == MyObject
120+
121+
111122
def test_pageinfo():
112123
assert PageInfo._meta.name == "PageInfo"
113124
fields = PageInfo._meta.fields

0 commit comments

Comments
 (0)