Moved relay is_node definition

This commit is contained in:
Syrus Akbary 2016-08-14 02:19:37 -07:00
parent f4062c3fc3
commit a0228ae6b2
3 changed files with 12 additions and 11 deletions

View File

@ -1,9 +1,10 @@
from .node import Node from .node import Node, is_node
from .mutation import ClientIDMutation from .mutation import ClientIDMutation
from .connection import Connection, ConnectionField from .connection import Connection, ConnectionField
__all__ = [ __all__ = [
'Node', 'Node',
'is_node',
'ClientIDMutation', 'ClientIDMutation',
'Connection', 'Connection',
'ConnectionField', 'ConnectionField',

View File

@ -12,18 +12,11 @@ from ..types.objecttype import ObjectType, ObjectTypeMeta
from ..types.options import Options from ..types.options import Options
from ..utils.is_base_type import is_base_type from ..utils.is_base_type import is_base_type
from ..utils.props import props 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 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): class PageInfo(ObjectType):
has_next_page = Boolean( has_next_page = Boolean(
required=True, required=True,
@ -125,8 +118,8 @@ class IterableConnectionField(Field):
else: else:
connection_type = type connection_type = type
assert issubclass(connection_type, Connection), ( assert issubclass(connection_type, Connection), (
'{} type have to be a subclass of Connection' '{} type have to be a subclass of Connection. Received "{}".'
).format(str(self)) ).format(str(self), connection_type)
return connection_type return connection_type
@staticmethod @staticmethod

View File

@ -7,6 +7,13 @@ from ..types import ObjectType, Interface, ID, Field
from ..types.interface import InterfaceMeta 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): def get_default_connection(cls):
from .connection import Connection from .connection import Connection
assert issubclass(cls, ObjectType), ( assert issubclass(cls, ObjectType), (