Skip to content

Commit 2cc701f

Browse files
committed
Improved is_node checks
1 parent bb6dc43 commit 2cc701f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

graphene/relay/node.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from collections import OrderedDict
22
from functools import partial
3+
from inspect import isclass
34

45
from graphql_relay import from_global_id, to_global_id
56

@@ -12,12 +13,16 @@ def is_node(objecttype):
1213
'''
1314
Check if the given objecttype has Node as an interface
1415
'''
16+
if not isclass(objecttype):
17+
return False
18+
1519
if not issubclass(objecttype, ObjectType):
1620
return False
1721

1822
for i in objecttype._meta.interfaces:
1923
if issubclass(i, Node):
2024
return True
25+
2126
return False
2227

2328

@@ -49,7 +54,8 @@ def __init__(self, node, type=False, deprecation_reason=None,
4954
self.field_type = type
5055

5156
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
5359
type or node,
5460
description='The ID of the object',
5561
id=ID(required=True)
@@ -70,7 +76,8 @@ def __init_subclass_with_meta__(cls, **options):
7076
_meta.fields = OrderedDict(
7177
id=GlobalID(cls, description='The ID of the object.')
7278
)
73-
super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)
79+
super(AbstractNode, cls).__init_subclass_with_meta__(
80+
_meta=_meta, **options)
7481

7582

7683
class Node(AbstractNode):

0 commit comments

Comments
 (0)