mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Fixed node id fetching when cannot decode. Fixed #14
This commit is contained in:
parent
34d6d07fc3
commit
d2ca8a96a9
|
@ -81,7 +81,10 @@ class NodeField(Field):
|
||||||
def id_fetcher(self, global_id, info):
|
def id_fetcher(self, global_id, info):
|
||||||
from graphene.relay.utils import is_node
|
from graphene.relay.utils import is_node
|
||||||
schema = info.schema.graphene_schema
|
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
|
_type, _id = resolved_global_id.type, resolved_global_id.id
|
||||||
object_type = schema.get_type(_type)
|
object_type = schema.get_type(_type)
|
||||||
if not is_node(object_type) or (self.field_object_type and
|
if not is_node(object_type) or (self.field_object_type and
|
||||||
|
|
|
@ -38,6 +38,10 @@ def test_nodefield_query():
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
},
|
},
|
||||||
|
false: myNode(id:"WrongNodeId") {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
},
|
||||||
allMyNodes (customArg:"1") {
|
allMyNodes (customArg:"1") {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
@ -56,6 +60,7 @@ def test_nodefield_query():
|
||||||
'id': 'TXlOb2RlOjE=',
|
'id': 'TXlOb2RlOjE=',
|
||||||
'name': 'mo'
|
'name': 'mo'
|
||||||
},
|
},
|
||||||
|
'false': None,
|
||||||
'allMyNodes': {
|
'allMyNodes': {
|
||||||
'edges': [{
|
'edges': [{
|
||||||
'node': {
|
'node': {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user