Skip to content

Commit 0fea0b0

Browse files
Fix to add support to Union in graphene federation
1 parent c9874ae commit 0fea0b0

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

graphene_mongo/converter.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import uuid
66

77
from graphene.types.json import JSONString
8-
from graphene.utils.str_converters import to_snake_case
8+
from graphene.utils.str_converters import to_snake_case, to_camel_case
99
from mongoengine.base import get_document, LazyReference
1010
from . import advanced_types
1111
from .utils import import_single_dispatch, get_field_description, get_query_fields
@@ -233,12 +233,10 @@ def convert_field_to_union(field, registry=None):
233233
if len(_types) == 0:
234234
return None
235235

236-
# XXX: Use uuid to avoid duplicate name
237-
name = "{}_{}_union_{}".format(
236+
name = to_camel_case("{}_{}".format(
238237
field._owner_document.__name__,
239-
field.db_field,
240-
str(uuid.uuid1()).replace("-", ""),
241-
)
238+
field.db_field
239+
)) + "UnionType"
242240
Meta = type("Meta", (object,), {"types": tuple(_types)})
243241
_union = type(name, (graphene.Union,), {"Meta": Meta})
244242

0 commit comments

Comments
 (0)