Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Use both id and email as federation key

Jakub Draganekaf4d78a4b81b
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.py
index 5e2c78bed4..b15c34a14d 100644
--- a/saleor/graphql/account/types.py
+++ b/saleor/graphql/account/types.py
@@ -228,7 +228,8 @@ class ServiceAccount(MetadataObjectType, CountableDjangoObjectType):
return graphene.Node.get_node_from_global_id(_info, root.id)
-@key(fields="id")
+@key("id")
+@key("email")
class User(MetadataObjectType, CountableDjangoObjectType):
addresses = gql_optimizer.field(
graphene.List(Address, description="List of all user's addresses."),
@@ -353,7 +354,9 @@ class User(MetadataObjectType, CountableDjangoObjectType):
@staticmethod
def __resolve_reference(root, _info, **_kwargs):
- return graphene.Node.get_node_from_global_id(_info, root.id)
+ if root.id is not None:
+ return graphene.Node.get_node_from_global_id(_info, root.id)
+ return get_user_model().objects.get(email=root.email)
class ChoiceValue(graphene.ObjectType):