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 .connection import Connection, ConnectionField
__all__ = [
'Node',
'is_node',
'ClientIDMutation',
'Connection',
'ConnectionField',

View File

@ -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

View File

@ -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), (