Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Return product type in mutation to delete attributes
Marcin Gębalabe5e7ecb0937
diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.pyindex d49828ee71..d561ad2b19 100644--- a/saleor/graphql/product/mutations/attributes.py+++ b/saleor/graphql/product/mutations/attributes.py@@ -253,6 +253,12 @@ class AttributeDelete(ModelDeleteMutation):def user_is_allowed(cls, user, input):return user.has_perm('product.manage_products')+ @classmethod+ def success_response(cls, instance):+ response = super().success_response(instance)+ response.product_type = instance.product_type+ return response+class AttributeValueCreateInput(graphene.InputObjectType):name = graphene.String(diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.pyindex 1ee3bbc611..0fe4c37f8a 100644--- a/tests/api/test_attributes.py+++ b/tests/api/test_attributes.py@@ -324,14 +324,22 @@ def test_update_attribute_and_remove_others_attribute_value(def test_delete_attribute(- staff_api_client, color_attribute, permission_manage_products):+ staff_api_client, color_attribute, permission_manage_products,+ product_type):attribute = color_attributequery = """mutation deleteAttribute($id: ID!) {attributeDelete(id: $id) {+ errors {+ field+ message+ }attribute {id}+ productType {+ name+ }}}"""@@ -340,6 +348,8 @@ def test_delete_attribute(response = staff_api_client.post_graphql(query, variables, permissions=[permission_manage_products])content = get_graphql_content(response)+ data = content['data']['attributeDelete']+ assert data['productType']['name'] == attribute.product_type.namewith pytest.raises(attribute._meta.model.DoesNotExist):attribute.refresh_from_db()