Add a helpful message to when a global_id fails to parse.

This commit is contained in:
James 2019-09-26 12:54:40 -05:00 committed by Jonathan Kim
parent 55a03ba716
commit 1afcdb03e0

View File

@ -91,9 +91,13 @@ class Node(AbstractNode):
try:
_type, _id = cls.from_global_id(global_id)
graphene_type = info.schema.get_type(_type).graphene_type
except Exception:
return None
except Exception as e:
raise Exception(
"Unable call from_global_id, is the id base64 encoding of 'TypeName:id': {} Exception: {}".format(
str(global_id),
str(e)
)
)
if only_type:
assert graphene_type == only_type, ("Must receive a {} id.").format(
only_type._meta.name