Fixed node id fetching when cannot decode. Fixed #14

This commit is contained in:
Syrus Akbary 2015-11-15 01:13:56 -06:00
parent 34d6d07fc3
commit d2ca8a96a9
2 changed files with 9 additions and 1 deletions

View File

@ -81,7 +81,10 @@ class NodeField(Field):
def id_fetcher(self, global_id, info):
from graphene.relay.utils import is_node
schema = info.schema.graphene_schema
resolved_global_id = from_global_id(global_id)
try:
resolved_global_id = from_global_id(global_id)
except:
return None
_type, _id = resolved_global_id.type, resolved_global_id.id
object_type = schema.get_type(_type)
if not is_node(object_type) or (self.field_object_type and

View File

@ -38,6 +38,10 @@ def test_nodefield_query():
id
name
},
false: myNode(id:"WrongNodeId") {
id
name
},
allMyNodes (customArg:"1") {
edges {
node {
@ -56,6 +60,7 @@ def test_nodefield_query():
'id': 'TXlOb2RlOjE=',
'name': 'mo'
},
'false': None,
'allMyNodes': {
'edges': [{
'node': {