Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add error enums for stock and warehouse
Mira Szewczyk025d22f7248b
diff --git a/saleor/graphql/core/enums.py b/saleor/graphql/core/enums.pyindex 3f4dae06c8..9400e24c35 100644--- a/saleor/graphql/core/enums.py+++ b/saleor/graphql/core/enums.py@@ -13,6 +13,8 @@ from ...order import error_codes as order_error_codesfrom ...payment import error_codes as payment_error_codesfrom ...product import error_codes as product_error_codesfrom ...shipping import error_codes as shipping_error_codes+from ...stock import error_codes as stock_error_codes+from ...warehouse import error_codes as warehouse_error_codesfrom ...webhook import error_codes as webhook_error_codesfrom ...wishlist import error_codes as wishlist_error_codesfrom .utils import str_to_enum@@ -93,5 +95,7 @@ PaymentErrorCode = graphene.Enum.from_enum(payment_error_codes.PaymentErrorCode)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)WebhookErrorCode = graphene.Enum.from_enum(webhook_error_codes.WebhookErrorCode)WishlistErrorCode = graphene.Enum.from_enum(wishlist_error_codes.WishlistErrorCode)diff --git a/saleor/graphql/core/types/common.py b/saleor/graphql/core/types/common.pyindex 0b1dbf2cba..013b9b9db0 100644--- a/saleor/graphql/core/types/common.py+++ b/saleor/graphql/core/types/common.py@@ -14,6 +14,8 @@ from ..enums import (ProductErrorCode,ShippingErrorCode,ShopErrorCode,+ StockErrorCode,+ WarehouseErrorCode,WebhookErrorCode,WishlistErrorCode,)@@ -86,8 +88,12 @@ class ExtensionsError(Error):code = ExtensionsErrorCode(description="The error code.")+class StockError(Error):+ code = StockErrorCode(description="The error code.")++class WarehouseError(Error):- code = ExtensionsErrorCode(description="The error code.")+ code = WarehouseErrorCode(description="The error code.")class WebhookError(Error):diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex a279f89231..64631fe830 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -4578,10 +4578,19 @@ type WarehouseDelete {warehouse: Warehouse}+enum WarehouseErorrCode {+ ALREADY_EXISTS+ GRAPHQL_ERROR+ INVALID+ NOT_FOUND+ REQUIRED+ UNIQUE+}+type WarehouseError {field: Stringmessage: String- code: ExtensionsErrorCode+ code: WarehouseErorrCode}input WarehouseFilterInput {diff --git a/saleor/stock/error_codes.py b/saleor/stock/error_codes.pynew file mode 100644index 0000000000..090de496e8--- /dev/null+++ b/saleor/stock/error_codes.py@@ -0,0 +1,10 @@+from enum import Enum+++class StockErorrCode(Enum):+ ALREADY_EXISTS = "already_exists"+ GRAPHQL_ERROR = "graphql_error"+ INVALID = "invalid"+ NOT_FOUND = "not_found"+ REQUIRED = "required"+ UNIQUE = "unique"diff --git a/saleor/warehouse/error_codes.py b/saleor/warehouse/error_codes.pynew file mode 100644index 0000000000..270fe882a3--- /dev/null+++ b/saleor/warehouse/error_codes.py@@ -0,0 +1,10 @@+from enum import Enum+++class WarehouseErorrCode(Enum):+ ALREADY_EXISTS = "already_exists"+ GRAPHQL_ERROR = "graphql_error"+ INVALID = "invalid"+ NOT_FOUND = "not_found"+ REQUIRED = "required"+ UNIQUE = "unique"