1
1
from collections import OrderedDict
2
2
from functools import partial
3
+ from inspect import isclass
3
4
4
5
from graphql_relay import from_global_id , to_global_id
5
6
@@ -12,12 +13,16 @@ def is_node(objecttype):
12
13
'''
13
14
Check if the given objecttype has Node as an interface
14
15
'''
16
+ if not isclass (objecttype ):
17
+ return False
18
+
15
19
if not issubclass (objecttype , ObjectType ):
16
20
return False
17
21
18
22
for i in objecttype ._meta .interfaces :
19
23
if issubclass (i , Node ):
20
24
return True
25
+
21
26
return False
22
27
23
28
@@ -49,7 +54,8 @@ def __init__(self, node, type=False, deprecation_reason=None,
49
54
self .field_type = type
50
55
51
56
super (NodeField , self ).__init__ (
52
- # If we don's specify a type, the field type will be the node interface
57
+ # If we don's specify a type, the field type will be the node
58
+ # interface
53
59
type or node ,
54
60
description = 'The ID of the object' ,
55
61
id = ID (required = True )
@@ -70,7 +76,8 @@ def __init_subclass_with_meta__(cls, **options):
70
76
_meta .fields = OrderedDict (
71
77
id = GlobalID (cls , description = 'The ID of the object.' )
72
78
)
73
- super (AbstractNode , cls ).__init_subclass_with_meta__ (_meta = _meta , ** options )
79
+ super (AbstractNode , cls ).__init_subclass_with_meta__ (
80
+ _meta = _meta , ** options )
74
81
75
82
76
83
class Node (AbstractNode ):
0 commit comments