Skip to content

Commit

Permalink
Allow the connection node to be wrapped in a NonNull type (#934)
Browse files Browse the repository at this point in the history
  • Loading branch information
minhtule authored and ekampf committed Apr 12, 2019
1 parent daf0d17 commit abff3d7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion graphene/relay/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Meta:
def __init_subclass_with_meta__(cls, node=None, name=None, **options):
_meta = ConnectionOptions(cls)
assert node, "You have to provide a node in {}.Meta".format(cls.__name__)
assert issubclass(
assert isinstance(node, NonNull) or issubclass(
node, (Scalar, Enum, ObjectType, Interface, Union, NonNull)
), ('Received incompatible node "{}" for Connection {}.').format(
node, cls.__name__
Expand Down
11 changes: 11 additions & 0 deletions graphene/relay/tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ class Edge(BaseEdge):
assert edge_fields["other"].type == String


def test_edge_with_nonnull_node():
class MyObjectConnection(Connection):
class Meta:
node = NonNull(MyObject)

edge_fields = MyObjectConnection.Edge._meta.fields
assert isinstance(edge_fields["node"], Field)
assert isinstance(edge_fields["node"].type, NonNull)
assert edge_fields["node"].type.of_type == MyObject


def test_pageinfo():
assert PageInfo._meta.name == "PageInfo"
fields = PageInfo._meta.fields
Expand Down

0 comments on commit abff3d7

Please sign in to comment.