From 4e0e18d1682b7759bdf16499c573f675c7fb51cb Mon Sep 17 00:00:00 2001 From: Jonny Wylie Date: Tue, 19 Apr 2022 07:21:21 +0100 Subject: [PATCH] Complete Support for core 2.3.0 - graphql-relay from_global_id no longer throws an exception if we fail to decode the id. - So handle the case of it returning empty strings instead. --- graphene/relay/node.py | 7 +++++++ graphene/test/__init__.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/graphene/relay/node.py b/graphene/relay/node.py index 8defefff..75e88cb7 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -97,6 +97,13 @@ class Node(AbstractNode): f"Exception message: {str(e)}" ) + # from_global_id returns "" in the case of decode errors + if _type == "" and _id == "": + raise Exception( + f'Unable to parse global ID "{global_id}". ' + 'Make sure it is a base64 encoded string in the format: "TypeName:id". ' + ) + graphene_type = info.schema.get_type(_type) if graphene_type is None: raise Exception(f'Relay Node "{_type}" not found in schema') diff --git a/graphene/test/__init__.py b/graphene/test/__init__.py index 8591dc06..517d8997 100644 --- a/graphene/test/__init__.py +++ b/graphene/test/__init__.py @@ -1,5 +1,5 @@ from promise import Promise, is_thenable -from graphql.error import format_error as format_graphql_error +from graphql.error.graphql_error import format_error as format_graphql_error from graphql.error import GraphQLError from graphene.types.schema import Schema