Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
change webhooks to be called on commit within atomic transactions (#9532)
Jakub1a4aed545eab
diff --git a/saleor/graphql/page/mutations/pages.py b/saleor/graphql/page/mutations/pages.pyindex 80eda6a4bd..5ecb277fcb 100644--- a/saleor/graphql/page/mutations/pages.py+++ b/saleor/graphql/page/mutations/pages.py@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, Dict, Listimport graphenefrom django.core.exceptions import ValidationError+from django.db import transactionfrom ....attribute import AttributeInputType, AttributeTypefrom ....attribute import models as attribute_models@@ -160,7 +161,7 @@ class PageDelete(ModelDeleteMutation):page = cls.get_instance(info, **data)cls.delete_assigned_attribute_values(page)response = super().perform_mutation(_root, info, **data)- info.context.plugins.page_deleted(page)+ transaction.on_commit(lambda: info.context.plugins.page_deleted(page))return response@staticmethoddiff --git a/saleor/graphql/product/mutations/channels.py b/saleor/graphql/product/mutations/channels.pyindex ddc1e2e231..35b486ddbf 100644--- a/saleor/graphql/product/mutations/channels.py+++ b/saleor/graphql/product/mutations/channels.py@@ -272,7 +272,7 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):def save(cls, info, product: "ProductModel", cleaned_input: Dict):cls.update_channels(product, cleaned_input.get("update_channels", []))cls.remove_channels(product, cleaned_input.get("remove_channels", []))- info.context.plugins.product_updated(product)+ transaction.on_commit(lambda: info.context.plugins.product_updated(product))@classmethoddef perform_mutation(cls, _root, info, id, input):diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 77bdf686a7..8af9db6ea3 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -775,7 +775,9 @@ class ProductDelete(ModelDeleteMutation):order_pks = draft_order_lines_data.order_pksif order_pks:recalculate_orders_task.delay(list(order_pks))- info.context.plugins.product_deleted(instance, variants_id)+ transaction.on_commit(+ lambda: info.context.plugins.product_deleted(instance, variants_id)+ )return response