Skip to content

Commit 959e98e

Browse files
author
Andrew Bettke
committed
Refactor to use formal to_global_id.
1 parent a461e80 commit 959e98e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

graphene_django/tests/test_query.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from django.db.models import Q
1010

11+
from graphql_relay import to_global_id
1112
import graphene
1213
from graphene.relay import Node
1314

@@ -947,19 +948,16 @@ class Query(graphene.ObjectType):
947948
}
948949
"""
949950

950-
def str_to_node_id(val):
951-
return base64.b64encode(val.encode()).decode()
952-
953951
expected = {
954952
"allReporters": {
955953
"edges": [
956-
{"node": {"id": str_to_node_id("ReporterType:{}".format(reporter.id))}},
957-
{"node": {"id": str_to_node_id("ReporterType:{}".format(cnn_reporter.id))}},
954+
{"node": {"id": to_global_id("ReporterType", reporter.id)}},
955+
{"node": {"id": to_global_id("ReporterType", cnn_reporter.id)}},
958956
]
959957
},
960958
"cnnReporters": {
961959
"edges": [
962-
{"node": {"id": str_to_node_id("CNNReporterType:{}".format(cnn_reporter.id))}}
960+
{"node": {"id": to_global_id("CNNReporterType", cnn_reporter.id)}}
963961
]
964962
}
965963
}

0 commit comments

Comments
 (0)