From 38baf7ab52f164db61df2c83d27102b0f3860cae Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Sat, 17 Feb 2018 20:18:55 +0000 Subject: [PATCH] Handle relay connection field being required --- graphene/relay/connection.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index aa2eeec3..1ea672fb 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -99,7 +99,10 @@ class IterableConnectionField(Field): def type(self): type = super(IterableConnectionField, self).type connection_type = type - if is_node(type): + if isinstance(type, NonNull): + connection_type = type.of_type + + if is_node(connection_type): raise Exception( "ConnectionField's now need a explicit ConnectionType for Nodes.\n" "Read more: https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#node-connections" @@ -108,10 +111,13 @@ class IterableConnectionField(Field): assert issubclass(connection_type, Connection), ( '{} type have to be a subclass of Connection. Received "{}".' ).format(self.__class__.__name__, connection_type) - return connection_type + return type @classmethod def resolve_connection(cls, connection_type, args, resolved): + if isinstance(connection_type, NonNull): + connection_type = connection_type.of_type + if isinstance(resolved, connection_type): return resolved