Skip to content

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

Fix typo and assign error code

Mira Szewczyk93349a380633
diff --git a/saleor/graphql/core/enums.py b/saleor/graphql/core/enums.py
index 9400e24c35..5366ce3ec7 100644
--- a/saleor/graphql/core/enums.py
+++ b/saleor/graphql/core/enums.py
@@ -96,6 +96,6 @@ ProductErrorCode = graphene.Enum.from_enum(product_error_codes.ProductErrorCode)
ShopErrorCode = graphene.Enum.from_enum(shop_error_codes.ShopErrorCode)
ShippingErrorCode = graphene.Enum.from_enum(shipping_error_codes.ShippingErrorCode)
StockErrorCode = graphene.Enum.from_enum(stock_error_codes.StockErorrCode)
-WarehouseErrorCode = graphene.Enum.from_enum(warehouse_error_codes.WarehouseErorrCode)
+WarehouseErrorCode = graphene.Enum.from_enum(warehouse_error_codes.WarehouseErrorCode)
WebhookErrorCode = graphene.Enum.from_enum(webhook_error_codes.WebhookErrorCode)
WishlistErrorCode = graphene.Enum.from_enum(wishlist_error_codes.WishlistErrorCode)
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 667050d8f3..80f33b118d 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -4656,7 +4656,13 @@ type WarehouseDelete {
warehouse: Warehouse
}
-enum WarehouseErorrCode {
+type WarehouseError {
+ field: String
+ message: String
+ code: WarehouseErrorCode
+}
+
+enum WarehouseErrorCode {
ALREADY_EXISTS
GRAPHQL_ERROR
INVALID
@@ -4665,12 +4671,6 @@ enum WarehouseErorrCode {
UNIQUE
}
-type WarehouseError {
- field: String
- message: String
- code: WarehouseErorrCode
-}
-
input WarehouseFilterInput {
search: String
}
diff --git a/saleor/graphql/warehouse/mutations.py b/saleor/graphql/warehouse/mutations.py
index 3e4efe99ae..440a648ee4 100644
--- a/saleor/graphql/warehouse/mutations.py
+++ b/saleor/graphql/warehouse/mutations.py
@@ -3,6 +3,7 @@ from django.core.exceptions import ValidationError
from ...shipping.models import ShippingZone
from ...warehouse import models
+from ...warehouse.error_codes import WarehouseErrorCode
from ..account.i18n import I18nMixin
from ..core.mutations import ModelDeleteMutation, ModelMutation
from ..core.types.common import WarehouseError
@@ -49,7 +50,9 @@ class WarehouseMixin:
shipping_zones = cleaned_input.get("shipping_zones", [])
if not cls.validate_warehouse_count(shipping_zones, instance):
msg = "Shipping zone can be assigned only to one warehouse."
- raise ValidationError({"shipping_zones": msg})
+ raise ValidationError(
+ {"shipping_zones": msg}, code=WarehouseErrorCode.INVALID
+ )
return cleaned_input
@classmethod
@@ -81,7 +84,7 @@ class WarehouseUpdate(WarehouseMixin, ModelMutation, I18nMixin):
class Meta:
model = models.Warehouse
permissions = ("warehouse.manage_warehouses",)
- description = "Update given warehouse."
+ description = "Updates given warehouse."
error_type_class = WarehouseError
error_type_field = "warehouse_errors"
diff --git a/saleor/warehouse/error_codes.py b/saleor/warehouse/error_codes.py
index 0a8a70f01b..1828c4e54c 100644
--- a/saleor/warehouse/error_codes.py
+++ b/saleor/warehouse/error_codes.py
@@ -1,7 +1,7 @@
from enum import Enum
-class WarehouseErorrCode(str, Enum):
+class WarehouseErrorCode(str, Enum):
ALREADY_EXISTS = "already_exists"
GRAPHQL_ERROR = "graphql_error"
INVALID = "invalid"