diff --git a/graphene/relay/__init__.py b/graphene/relay/__init__.py index 1a20ec41..41f6a810 100644 --- a/graphene/relay/__init__.py +++ b/graphene/relay/__init__.py @@ -1,9 +1,10 @@ -from .node import Node +from .node import Node, is_node from .mutation import ClientIDMutation from .connection import Connection, ConnectionField __all__ = [ 'Node', + 'is_node', 'ClientIDMutation', 'Connection', 'ConnectionField', diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index 71563aed..89503e8c 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -12,18 +12,11 @@ from ..types.objecttype import ObjectType, ObjectTypeMeta from ..types.options import Options from ..utils.is_base_type import is_base_type from ..utils.props import props -from .node import Node +from .node import Node, is_node from ..types.utils import get_fields_in_type, yank_fields_from_attrs -def is_node(objecttype): - for i in objecttype._meta.interfaces: - if issubclass(i, Node): - return True - return False - - class PageInfo(ObjectType): has_next_page = Boolean( required=True, @@ -125,8 +118,8 @@ class IterableConnectionField(Field): else: connection_type = type assert issubclass(connection_type, Connection), ( - '{} type have to be a subclass of Connection' - ).format(str(self)) + '{} type have to be a subclass of Connection. Received "{}".' + ).format(str(self), connection_type) return connection_type @staticmethod diff --git a/graphene/relay/node.py b/graphene/relay/node.py index 80459f2f..d93393ec 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -7,6 +7,13 @@ from ..types import ObjectType, Interface, ID, Field from ..types.interface import InterfaceMeta +def is_node(objecttype): + for i in objecttype._meta.interfaces: + if issubclass(i, Node): + return True + return False + + def get_default_connection(cls): from .connection import Connection assert issubclass(cls, ObjectType), (