Skip to content

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

Add errors info to mutations

Mira Szewczyke1c679c842e7
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index e6b9551f01..404d7df9bb 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -2079,7 +2079,7 @@ type Mutation {
webhookDelete(id: ID!): WebhookDelete
webhookUpdate(id: ID!, input: WebhookUpdateInput!): WebhookUpdate
createWarehouse(input: WarehouseCreateInput!): WarehouseCreate
- updateWarehouse(id: ID!, input: WarehouseUpdateInput): WarehouseUpdate
+ updateWarehouse(id: ID!, input: WarehouseUpdateInput!): WarehouseUpdate
deleteWarehouse(id: ID!): WarehouseDelete
authorizationKeyAdd(input: AuthorizationKeyInput!, keyType: AuthorizationKeyType!): AuthorizationKeyAdd
authorizationKeyDelete(keyType: AuthorizationKeyType!): AuthorizationKeyDelete
@@ -4561,6 +4561,7 @@ type WarehouseCountableEdge {
type WarehouseCreate {
errors: [Error!]
+ warehouseErrors: [WarehouseError!]
warehouse: Warehouse
}
@@ -4586,6 +4587,7 @@ type WarehouseError {
type WarehouseUpdate {
errors: [Error!]
+ warehouseErrors: [WarehouseError!]
warehouse: Warehouse
}
diff --git a/saleor/graphql/warehouse/mutations.py b/saleor/graphql/warehouse/mutations.py
index 49b6664fb1..9d537beed9 100644
--- a/saleor/graphql/warehouse/mutations.py
+++ b/saleor/graphql/warehouse/mutations.py
@@ -28,6 +28,8 @@ class WarehouseCreate(ModelMutation):
description = "Creates new warehouse."
model = models.Warehouse
permissions = ("warehouse.manage_warehouses",)
+ error_type_class = WarehouseError
+ error_type_field = "warehouse_errors"
@classmethod
def create_address(cls, clean_data):
@@ -47,10 +49,12 @@ class WarehouseUpdate(ModelMutation):
model = models.Warehouse
permissions = ("warehouse.manage_warehouses",)
description = "Update given warehouse."
+ error_type_class = WarehouseError
+ error_type_field = "warehouse_errors"
class Arguments:
id = graphene.ID(description="ID of a warehouse to update.", required=True)
- input = WarehouseUpdateInput()
+ input = WarehouseUpdateInput(required=True)
@classmethod
def update_address(cls, instance, cleaned_data):