Skip to content

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

Fix response in addressUpdate mutation

Marcin Gębala29fab3036afb
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index 493538e1ae..a5e41730d0 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -442,6 +442,9 @@ class AddressCreate(ModelMutation):
class AddressUpdate(ModelMutation):
+ user = graphene.Field(
+ User, description='A user instance for which the address was edited.')
+
class Arguments:
id = graphene.ID(
description='ID of the address to update', required=True)
@@ -461,6 +464,13 @@ class AddressUpdate(ModelMutation):
raise PermissionDenied()
return super().clean_input(info, instance, input, errors)
+ @classmethod
+ def mutate(cls, root, info, **data):
+ response = super().mutate(root, info, **data)
+ user = response.address.user_addresses.first()
+ response.user = user
+ return response
+
class AddressDelete(ModelDeleteMutation):
user = graphene.Field(
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index c4dfdef138..ec6c636eb2 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -58,6 +58,7 @@ enum AddressTypeEnum {
type AddressUpdate {
errors: [Error!]
+ user: User
address: Address
}
diff --git a/tests/api/test_account.py b/tests/api/test_account.py
index 2a18c033ba..6b0fe2f43f 100644
--- a/tests/api/test_account.py
+++ b/tests/api/test_account.py
@@ -1097,6 +1097,9 @@ ADDRESS_DELETE_MUTATION = """
address {
city
}
+ user {
+ id
+ }
}
}
"""