Black the node.py file

This commit is contained in:
James 2019-09-26 13:25:15 -05:00 committed by Jonathan Kim
parent 4f1144c543
commit 68cdddd0b0

View File

@ -1,3 +1,4 @@
from collections import OrderedDict
from functools import partial from functools import partial
from inspect import isclass from inspect import isclass
@ -61,7 +62,14 @@ class NodeField(Field):
) )
def get_resolver(self, parent_resolver): def get_resolver(self, parent_resolver):
return partial(self.node_type.node_resolver, get_type(self.field_type)) def return_partial(*args, **kwargs):
print("\n\nDebugging get_resolver: ")
print(parent_resolver, args, kwargs)
return partial(self.node_type.node_resolver, get_type(self.field_type))(
*args, **kwargs
)
return return_partial
class AbstractNode(Interface): class AbstractNode(Interface):
@ -71,7 +79,9 @@ class AbstractNode(Interface):
@classmethod @classmethod
def __init_subclass_with_meta__(cls, **options): def __init_subclass_with_meta__(cls, **options):
_meta = InterfaceOptions(cls) _meta = InterfaceOptions(cls)
_meta.fields = {"id": GlobalID(cls, description="The ID of the object")} _meta.fields = OrderedDict(
id=GlobalID(cls, description="The ID of the object.")
)
super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options) super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)
@ -92,12 +102,8 @@ class Node(AbstractNode):
_type, _id = cls.from_global_id(global_id) _type, _id = cls.from_global_id(global_id)
graphene_type = info.schema.get_type(_type).graphene_type graphene_type = info.schema.get_type(_type).graphene_type
except Exception as e: except Exception as e:
raise Exception( print(e)
"Unable call from_global_id, is the id base64 encoding of 'TypeName:id': {} Exception: {}".format( raise
str(global_id),
str(e)
)
)
if only_type: if only_type:
assert graphene_type == only_type, ("Must receive a {} id.").format( assert graphene_type == only_type, ("Must receive a {} id.").format(
only_type._meta.name only_type._meta.name