Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix validation error when publishing a product without a category
Marcin Gębalaa85dbe3e7af6
diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 23aaabce9e..f56563bc29 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -861,8 +861,9 @@ class ProductCreate(ModelMutation):if not category and is_published:raise ValidationError({- "isPublished": ValidationError(- "You must select a category to be able to publish"+ "category": ValidationError(+ "You must select a category to be able to publish",+ code=ProductErrorCode.REQUIRED,)})diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.pyindex cfa794b681..ee6a3be744 100644--- a/saleor/graphql/product/tests/test_product.py+++ b/saleor/graphql/product/tests/test_product.py@@ -1590,8 +1590,8 @@ def test_product_create_without_category_and_true_is_published_value(product {id}- errors {- message+ productErrors {+ codefield}}@@ -1604,10 +1604,9 @@ def test_product_create_without_category_and_true_is_published_value({"productTypeId": product_type_id},permissions=[permission_manage_products],)- errors = get_graphql_content(response)["data"]["productCreate"]["errors"]-- assert errors[0]["field"] == "isPublished"- assert errors[0]["message"] == "You must select a category to be able to publish"+ errors = get_graphql_content(response)["data"]["productCreate"]["productErrors"]+ assert errors[0]["field"] == "category"+ assert errors[0]["code"] == ProductErrorCode.REQUIRED.namedef test_product_create_with_collections_webhook(@@ -2265,8 +2264,8 @@ def test_update_product_without_category_and_true_is_published_value(product {id}- errors {- message+ productErrors {+ codefield}}@@ -2283,12 +2282,9 @@ def test_update_product_without_category_and_true_is_published_value()data = get_graphql_content(response)["data"]["productUpdate"]- assert data["errors"]- assert data["errors"][0]["field"] == "isPublished"- assert (- data["errors"][0]["message"]- == "You must select a category to be able to publish"- )+ assert data["productErrors"]+ assert data["productErrors"][0]["field"] == "category"+ assert data["productErrors"][0]["code"] == ProductErrorCode.REQUIRED.nameUPDATE_PRODUCT = """