From 3fa65aa343ce535f0736eb6c7332f13620ba071b Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 3 Nov 2016 20:21:45 -0700 Subject: [PATCH] Improved connection type of checking --- graphene/relay/connection.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index d0dcaf22..3b1cac5a 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -95,6 +95,10 @@ class Connection(six.with_metaclass(ConnectionMeta, ObjectType)): def Field(cls, *args, **kwargs): # noqa: N802 return ConnectionField(cls, *args, **kwargs) + @classmethod + def is_type_of(cls, root, context, info): + return isinstance(root, cls) + @classmethod def connection_resolver(cls, resolved, args, context, info): assert isinstance(resolved, Iterable), ( @@ -132,7 +136,7 @@ class ConnectionField(Field): def connection_resolver(cls, resolver, connection_type, root, args, context, info): resolved = resolver(root, args, context, info) - if isinstance(resolved, connection_type): + if connection_type.is_type_of(resolved, context, info): return resolved on_resolve = partial(connection_type.connection_resolver, args=args, context=context, info=info)