Skip to content

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

Refresh user instance after removing address

Marcin Gębala131cb81dab46
diff --git a/saleor/graphql/account/mutations.py b/saleor/graphql/account/mutations.py
index be5a027fe6..493538e1ae 100644
--- a/saleor/graphql/account/mutations.py
+++ b/saleor/graphql/account/mutations.py
@@ -506,6 +506,13 @@ class AddressDelete(ModelDeleteMutation):
instance.id = db_id
response = cls.success_response(instance)
+
+ # Refresh the user instance to clear the default addresses. If the
+ # deleted address was used as default, it would stay cached in the
+ # user instance and the invalid ID returned in the response migt cause
+ # an error.
+ user.refresh_from_db()
+
response.user = user
return response