Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Meta fields added to subscription webhooks event types. (#9759)
SzymJf2ce999fa586
diff --git a/saleor/app/tests/test_installation_utils.py b/saleor/app/tests/test_installation_utils.pyindex 346b5653ca..c0b5bc9d97 100644--- a/saleor/app/tests/test_installation_utils.py+++ b/saleor/app/tests/test_installation_utils.py@@ -4,8 +4,10 @@ import grapheneimport pytestimport requestsfrom django.core.exceptions import ValidationError+from freezegun import freeze_timefrom ...webhook.event_types import WebhookEventAsyncType+from ...webhook.payloads import generate_meta, generate_requestorfrom ..installation_utils import install_appfrom ..models import Appfrom ..types import AppExtensionMount, AppExtensionTarget@@ -32,6 +34,7 @@ def test_install_app_created_app(assert list(app.permissions.all()) == [permission_manage_products]+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_install_app_created_app_trigger_webhook(@@ -66,6 +69,7 @@ def test_install_app_created_app_trigger_webhook("id": graphene.Node.to_global_id("App", app.id),"is_active": app.is_active,"name": app.name,+ "meta": generate_meta(requestor_data=generate_requestor()),},WebhookEventAsyncType.APP_INSTALLED,[any_webhook],diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex 6eaeed641a..00284b7308 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -26,7 +26,7 @@ from .shop.schema import ShopMutations, ShopQueriesfrom .translations.schema import TranslationQueriesfrom .warehouse.schema import StockQueries, WarehouseMutations, WarehouseQueriesfrom .webhook.schema import WebhookMutations, WebhookQueries-from .webhook.subscription_types import Subscription+from .webhook.subscription_types import SUBSCRIPTION_EVENTS_TYPES, SubscriptionAPI_PATH = SimpleLazyObject(lambda: reverse("api"))@@ -85,5 +85,8 @@ class Mutation(schema = build_federated_schema(- Query, mutation=Mutation, types=unit_enums, subscription=Subscription+ Query,+ mutation=Mutation,+ types=unit_enums + SUBSCRIPTION_EVENTS_TYPES,+ subscription=Subscription,)diff --git a/saleor/graphql/app/tests/mutations/test_app_activate.py b/saleor/graphql/app/tests/mutations/test_app_activate.pyindex 9fb1310e00..eb45107253 100644--- a/saleor/graphql/app/tests/mutations/test_app_activate.py+++ b/saleor/graphql/app/tests/mutations/test_app_activate.py@@ -2,9 +2,11 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....app.models import Appfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentAPP_ACTIVATE_MUTATION = """@@ -46,6 +48,7 @@ def test_activate_app(app, staff_api_client, permission_manage_apps):assert app.is_active+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_activate_app_trigger_webhook(@@ -83,6 +86,11 @@ def test_activate_app_trigger_webhook("id": variables["id"],"is_active": app.is_active,"name": app.name,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.APP_STATUS_CHANGED,[any_webhook],diff --git a/saleor/graphql/app/tests/mutations/test_app_create.py b/saleor/graphql/app/tests/mutations/test_app_create.pyindex 5f7f1eb070..8a6bb54cdd 100644--- a/saleor/graphql/app/tests/mutations/test_app_create.py+++ b/saleor/graphql/app/tests/mutations/test_app_create.py@@ -2,10 +2,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....app.error_codes import AppErrorCodefrom .....app.models import Appfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....core.enums import PermissionEnumfrom ....tests.utils import assert_no_permission, get_graphql_content@@ -67,6 +69,7 @@ def test_app_create_mutation(assert default_token[-4:] == app.tokens.get().token_last_4+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_app_create_trigger_webhook(@@ -104,6 +107,11 @@ def test_app_create_trigger_webhook("id": graphene.Node.to_global_id("App", app.id),"is_active": app.is_active,"name": app.name,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.APP_INSTALLED,[any_webhook],diff --git a/saleor/graphql/app/tests/mutations/test_app_deactivate.py b/saleor/graphql/app/tests/mutations/test_app_deactivate.pyindex caf7e84c29..1a6f2e2de9 100644--- a/saleor/graphql/app/tests/mutations/test_app_deactivate.py+++ b/saleor/graphql/app/tests/mutations/test_app_deactivate.py@@ -2,9 +2,11 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....app.models import Appfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentAPP_DEACTIVATE_MUTATION = """@@ -46,6 +48,7 @@ def test_deactivate_app(app, staff_api_client, permission_manage_apps):assert not app.is_active+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_deactivate_app_trigger_webhook(@@ -83,6 +86,11 @@ def test_deactivate_app_trigger_webhook("id": variables["id"],"is_active": app.is_active,"name": app.name,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.APP_STATUS_CHANGED,[any_webhook],diff --git a/saleor/graphql/app/tests/mutations/test_app_delete.py b/saleor/graphql/app/tests/mutations/test_app_delete.pyindex 612d12bedf..c9915df660 100644--- a/saleor/graphql/app/tests/mutations/test_app_delete.py+++ b/saleor/graphql/app/tests/mutations/test_app_delete.py@@ -2,10 +2,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....app.error_codes import AppErrorCodefrom .....app.models import Appfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentAPP_DELETE_MUTATION = """@@ -48,6 +50,7 @@ def test_app_delete(assert not App.objects.filter(id=app.id)+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_app_delete_trigger_webhook(@@ -84,6 +87,11 @@ def test_app_delete_trigger_webhook("id": app_global_id,"is_active": app.is_active,"name": app.name,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.APP_DELETED,[any_webhook],diff --git a/saleor/graphql/app/tests/mutations/test_app_update.py b/saleor/graphql/app/tests/mutations/test_app_update.pyindex eb79e016f2..00014053e3 100644--- a/saleor/graphql/app/tests/mutations/test_app_update.py+++ b/saleor/graphql/app/tests/mutations/test_app_update.py@@ -2,10 +2,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....app.error_codes import AppErrorCodefrom .....app.models import App, AppTokenfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....core.enums import PermissionEnumfrom ....tests.utils import assert_no_permission, get_graphql_content@@ -75,6 +77,7 @@ def test_app_update_mutation(}+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_app_update_trigger_mutation(@@ -118,6 +121,11 @@ def test_app_update_trigger_mutation("id": variables["id"],"is_active": app_with_token.is_active,"name": app_with_token.name,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.APP_UPDATED,[any_webhook],diff --git a/saleor/graphql/channel/tests/test_channel_availability.py b/saleor/graphql/channel/tests/test_channel_availability.pyindex e48d4627e9..a78c1dcc0a 100644--- a/saleor/graphql/channel/tests/test_channel_availability.py+++ b/saleor/graphql/channel/tests/test_channel_availability.py@@ -2,9 +2,11 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom ....channel.error_codes import ChannelErrorCodefrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import get_graphql_contentCHANNEL_ACTIVATE_MUTATION = """@@ -49,6 +51,7 @@ def test_channel_activate_mutation(assert data["channel"]["isActive"] is True+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_channel_activate_mutation_trigger_webhook(@@ -80,7 +83,15 @@ def test_channel_activate_mutation_trigger_webhook(# thenassert not content["data"]["channelActivate"]["errors"]mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"], "is_active": True},+ {+ "id": variables["id"],+ "is_active": True,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CHANNEL_STATUS_CHANGED,[any_webhook],channel_USD,@@ -149,6 +160,7 @@ def test_channel_deactivate_mutation(assert data["channel"]["isActive"] is False+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_channel_deactivate_mutation_trigger_webhook(@@ -178,7 +190,15 @@ def test_channel_deactivate_mutation_trigger_webhook(# thenassert not content["data"]["channelDeactivate"]["errors"]mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"], "is_active": False},+ {+ "id": variables["id"],+ "is_active": False,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CHANNEL_STATUS_CHANGED,[any_webhook],channel_USD,diff --git a/saleor/graphql/channel/tests/test_channel_create_mutations.py b/saleor/graphql/channel/tests/test_channel_create_mutations.pyindex 463fc0a32b..349078293b 100644--- a/saleor/graphql/channel/tests/test_channel_create_mutations.py+++ b/saleor/graphql/channel/tests/test_channel_create_mutations.py@@ -3,10 +3,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObjectfrom django.utils.text import slugify+from freezegun import freeze_timefrom ....channel.error_codes import ChannelErrorCodefrom ....channel.models import Channelfrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import assert_no_permission, get_graphql_contentCHANNEL_CREATE_MUTATION = """@@ -273,6 +275,7 @@ def test_channel_create_mutation_with_shipping_zones(shipping_zone.channels.get(slug=slug)+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_channel_create_mutation_trigger_webhook(@@ -315,7 +318,15 @@ def test_channel_create_mutation_trigger_webhook(assert not data["errors"]mocked_webhook_trigger.assert_called_once_with(- {"id": graphene.Node.to_global_id("Channel", channel.id)},+ {+ "id": graphene.Node.to_global_id("Channel", channel.id),+ "is_active": channel.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CHANNEL_CREATED,[any_webhook],channel,diff --git a/saleor/graphql/channel/tests/test_channel_delete_mutations.py b/saleor/graphql/channel/tests/test_channel_delete_mutations.pyindex 0148e57079..f4d74cfaf8 100644--- a/saleor/graphql/channel/tests/test_channel_delete_mutations.py+++ b/saleor/graphql/channel/tests/test_channel_delete_mutations.py@@ -2,12 +2,14 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom ....channel.error_codes import ChannelErrorCodefrom ....channel.models import Channelfrom ....checkout.models import Checkoutfrom ....order.models import Orderfrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import assert_no_permission, get_graphql_contentCHANNEL_DELETE_MUTATION = """@@ -231,6 +233,7 @@ def test_channel_delete_mutation_as_anonymous(assert Channel.objects.filter(slug=channel_USD.slug).exists()+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_channel_delete_mutation_trigger_webhook(@@ -265,7 +268,15 @@ def test_channel_delete_mutation_trigger_webhook(assert not Channel.objects.filter(slug=channel_USD.slug).exists()mocked_webhook_trigger.assert_called_once_with(- {"id": graphene.Node.to_global_id("Channel", channel_USD.id)},+ {+ "id": graphene.Node.to_global_id("Channel", channel_USD.id),+ "is_active": channel_USD.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CHANNEL_DELETED,[any_webhook],channel_USD,diff --git a/saleor/graphql/channel/tests/test_channel_update_mutations.py b/saleor/graphql/channel/tests/test_channel_update_mutations.pyindex 8755ed77d9..9a1dfcd261 100644--- a/saleor/graphql/channel/tests/test_channel_update_mutations.py+++ b/saleor/graphql/channel/tests/test_channel_update_mutations.py@@ -3,9 +3,11 @@ from unittest.mock import patchimport graphenefrom django.utils.functional import SimpleLazyObjectfrom django.utils.text import slugify+from freezegun import freeze_timefrom ....channel.error_codes import ChannelErrorCodefrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import assert_no_permission, get_graphql_contentCHANNEL_UPDATE_MUTATION = """@@ -410,6 +412,7 @@ def test_channel_update_mutation_duplicated_shipping_zone(assert errors[0]["shippingZones"] == [add_shipping_zone]+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_channel_update_mutation_trigger_webhook(@@ -448,7 +451,15 @@ def test_channel_update_mutation_trigger_webhook(assert data["channel"]mocked_webhook_trigger.assert_called_once_with(- {"id": channel_id},+ {+ "id": channel_id,+ "is_active": channel_USD.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CHANNEL_UPDATED,[any_webhook],channel_USD,diff --git a/saleor/graphql/discount/tests/test_discount.py b/saleor/graphql/discount/tests/test_discount.pyindex 6578b8bca8..591a0214e3 100644--- a/saleor/graphql/discount/tests/test_discount.py+++ b/saleor/graphql/discount/tests/test_discount.py@@ -14,6 +14,7 @@ from ....discount.models import Sale, SaleChannelListing, Voucherfrom ....discount.utils import fetch_catalogue_infofrom ....graphql.discount.mutations import convert_catalogue_info_to_global_idsfrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import (assert_no_permission,get_graphql_content,@@ -495,6 +496,7 @@ def test_create_voucher(staff_api_client, permission_manage_discounts):assert voucher.usage_limit == 3+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_create_voucher_trigger_webhook(@@ -538,6 +540,11 @@ def test_create_voucher_trigger_webhook("id": graphene.Node.to_global_id("Voucher", voucher.id),"name": voucher.name,"code": voucher.code,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.VOUCHER_CREATED,[any_webhook],@@ -703,6 +710,7 @@ def test_update_voucher(staff_api_client, voucher, permission_manage_discounts):assert data["minCheckoutItemsQuantity"] == 10+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_update_voucher_trigger_webhook(@@ -736,6 +744,11 @@ def test_update_voucher_trigger_webhook("id": variables["id"],"name": voucher.name,"code": variables["code"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.VOUCHER_UPDATED,[any_webhook],@@ -776,6 +789,7 @@ def test_voucher_delete_mutation(voucher.refresh_from_db()+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_voucher_delete_mutation_trigger_webhook(@@ -806,6 +820,11 @@ def test_voucher_delete_mutation_trigger_webhook("id": variables["id"],"name": voucher.name,"code": voucher.code,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.VOUCHER_DELETED,[any_webhook],@@ -871,6 +890,7 @@ def test_voucher_add_catalogues(assert set(product_variant_list) == set(voucher.variants.all())+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_voucher_add_catalogues_trigger_webhook(@@ -924,6 +944,11 @@ def test_voucher_add_catalogues_trigger_webhook("id": variables["id"],"name": voucher.name,"code": voucher.code,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.VOUCHER_UPDATED,[any_webhook],diff --git a/saleor/graphql/discount/tests/test_voucher_channel_listing.py b/saleor/graphql/discount/tests/test_voucher_channel_listing.pyindex 54162cbef2..ade6e21e2d 100644--- a/saleor/graphql/discount/tests/test_voucher_channel_listing.py+++ b/saleor/graphql/discount/tests/test_voucher_channel_listing.py@@ -2,10 +2,12 @@ from unittest.mock import patchimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom ....discount import DiscountValueTypefrom ....discount.error_codes import DiscountErrorCodefrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import assert_no_permission, get_graphql_contentVOUCHER_CHANNEL_LISTING_UPDATE_MUTATION = """@@ -122,6 +124,7 @@ def test_voucher_channel_listing_update_as_customer(assert_no_permission(response)+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_voucher_channel_listing_update_trigger_webhook(@@ -161,6 +164,11 @@ def test_voucher_channel_listing_update_trigger_webhook("id": variables["id"],"name": voucher.name,"code": voucher.code,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.VOUCHER_UPDATED,[any_webhook],diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_activate.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_activate.pyindex bf8c7f3178..44bbd5b323 100644--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_activate.py+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_activate.py@@ -3,10 +3,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....giftcard import GiftCardEventsfrom .....giftcard.error_codes import GiftCardErrorCodefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentACTIVATE_GIFT_CARD_MUTATION = """@@ -184,6 +186,7 @@ def test_activate_expired_gift_card(assert errors[0]["code"] == GiftCardErrorCode.EXPIRED_GIFT_CARD.name+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_activate_gift_card_trigger_webhook(@@ -223,7 +226,15 @@ def test_activate_gift_card_trigger_webhook(assert data["isActive"]mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"], "is_active": True},+ {+ "id": variables["id"],+ "is_active": True,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.GIFT_CARD_STATUS_CHANGED,[any_webhook],gift_card,diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_add_note.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_add_note.pyindex 34bf6435aa..7ad38add0a 100644--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_add_note.py+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_add_note.py@@ -4,10 +4,12 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....giftcard import GiftCardEventsfrom .....giftcard.error_codes import GiftCardErrorCodefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentGIFT_CARD_ADD_NOTE_MUTATION = """@@ -196,6 +198,7 @@ def test_gift_card_add_note_expired_card(assert event.parameters == {"message": message}+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_gift_card_add_note_trigger_webhook(@@ -238,6 +241,11 @@ def test_gift_card_add_note_trigger_webhook({"id": graphene.Node.to_global_id("GiftCard", gift_card.id),"is_active": gift_card.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.GIFT_CARD_UPDATED,[any_webhook],diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_create.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_create.pyindex 6ab98132b2..5bf3a7d44d 100644--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_create.py+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_create.py@@ -4,11 +4,13 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....giftcard import GiftCardEventsfrom .....giftcard.error_codes import GiftCardErrorCodefrom .....giftcard.models import GiftCardfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentCREATE_GIFT_CARD_MUTATION = """@@ -622,6 +624,7 @@ def test_create_gift_card_with_expiry_date_type_invalid(assert errors[0]["code"] == GiftCardErrorCode.INVALID.name+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_create_gift_card_trigger_webhook(@@ -674,6 +677,11 @@ def test_create_gift_card_trigger_webhook({"id": graphene.Node.to_global_id("GiftCard", gift_card.id),"is_active": gift_card.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: app_api_client.app)+ )+ ),},WebhookEventAsyncType.GIFT_CARD_CREATED,[any_webhook],diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_deactivate.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_deactivate.pyindex 5fece730b4..f57fb6624b 100644--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_deactivate.py+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_deactivate.py@@ -2,9 +2,11 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....giftcard import GiftCardEventsfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentDEACTIVATE_GIFT_CARD_MUTATION = """@@ -161,6 +163,7 @@ def test_deactivate_inactive_gift_card(assert not data["events"]+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_deactivate_gift_card_trigger_webhook(@@ -198,7 +201,15 @@ def test_deactivate_gift_card_trigger_webhook(assert not data["isActive"]mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"], "is_active": False},+ {+ "id": variables["id"],+ "is_active": False,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.GIFT_CARD_STATUS_CHANGED,[any_webhook],gift_card,diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_delete.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_delete.pyindex 99cf258faf..275e84be54 100644--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_delete.py+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_delete.py@@ -3,8 +3,10 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentDELETE_GIFT_CARD_MUTATION = """@@ -84,6 +86,7 @@ def test_delete_gift_card_by_customer(app_api_client, gift_card):assert_no_permission(response)+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_delete_gift_card_trigger_webhook(@@ -114,7 +117,15 @@ def test_delete_gift_card_trigger_webhook(assert data["id"] == idmocked_webhook_trigger.assert_called_once_with(- {"id": id, "is_active": gift_card.is_active},+ {+ "id": id,+ "is_active": gift_card.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.GIFT_CARD_DELETED,[any_webhook],gift_card,diff --git a/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py b/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.pyindex 1272fa52b1..30ef67ef55 100644--- a/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py+++ b/saleor/graphql/giftcard/tests/mutations/test_gift_card_update.py@@ -4,11 +4,13 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....giftcard import GiftCardEventsfrom .....giftcard.error_codes import GiftCardErrorCodefrom .....giftcard.models import GiftCardTagfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_no_permission, get_graphql_contentUPDATE_GIFT_CARD_MUTATION = """@@ -730,6 +732,7 @@ def test_update_gift_card_duplicated_tags_item(assert errors[0]["code"] == GiftCardErrorCode.DUPLICATED_INPUT_ITEM.name+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_update_gift_card_trigger_webhook(@@ -782,6 +785,11 @@ def test_update_gift_card_trigger_webhook({"id": graphene.Node.to_global_id("GiftCard", gift_card.id),"is_active": gift_card.is_active,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.GIFT_CARD_UPDATED,[any_webhook],diff --git a/saleor/graphql/menu/tests/test_menu.py b/saleor/graphql/menu/tests/test_menu.pyindex a92fa4d4c6..c6e34bd8c2 100644--- a/saleor/graphql/menu/tests/test_menu.py+++ b/saleor/graphql/menu/tests/test_menu.py@@ -5,11 +5,13 @@ import grapheneimport pytestfrom django.core.exceptions import ValidationErrorfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom ....menu.error_codes import MenuErrorCodefrom ....menu.models import Menu, MenuItemfrom ....product.models import Categoryfrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...menu.mutations import NavigationType, _validate_menu_item_instancefrom ...tests.utils import (assert_no_permission,@@ -632,6 +634,7 @@ def test_create_menu(assert content["data"]["menuCreate"]["menu"]["slug"] == "test-menu"+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_create_menu_trigger_webhook(@@ -675,6 +678,11 @@ def test_create_menu_trigger_webhook({"id": graphene.Node.to_global_id("Menu", menu.id),"slug": menu.slug,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.MENU_CREATED,[any_webhook],@@ -793,6 +801,7 @@ def test_update_menu_with_slug(staff_api_client, menu, permission_manage_menus):assert content["data"]["menuUpdate"]["menu"]["slug"] == "new-slug"+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_update_menu_trigger_webhook(@@ -827,6 +836,11 @@ def test_update_menu_trigger_webhook({"id": variables["id"],"slug": variables["slug"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.MENU_UPDATED,[any_webhook],@@ -881,6 +895,7 @@ def test_delete_menu(staff_api_client, menu, permission_manage_menus):menu.refresh_from_db()+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_delete_menu_trigger_webhook(@@ -911,6 +926,11 @@ def test_delete_menu_trigger_webhook({"id": variables["id"],"slug": menu.slug,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.MENU_DELETED,[any_webhook],@@ -949,6 +969,7 @@ def test_create_menu_item(staff_api_client, menu, permission_manage_menus):assert data["menu"]["name"] == menu.name+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_create_menu_item_trigger_webhook(@@ -983,6 +1004,11 @@ def test_create_menu_item_trigger_webhook("id": graphene.Node.to_global_id("MenuItem", menu_item.id),"name": menu_item.name,"menu": {"id": menu_id},+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.MENU_ITEM_CREATED,[any_webhook],@@ -1021,6 +1047,7 @@ def test_update_menu_item(assert data["page"]["id"] == page_id+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_update_menu_item_trigger_webhook(@@ -1058,6 +1085,11 @@ def test_update_menu_item_trigger_webhook("id": menu_item_id,"name": menu_item.name,"menu": {"id": graphene.Node.to_global_id("Menu", menu_item.menu_id)},+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.MENU_ITEM_UPDATED,[any_webhook],@@ -1090,6 +1122,7 @@ def test_delete_menu_item(staff_api_client, menu_item, permission_manage_menus):menu_item.refresh_from_db()+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_delete_menu_item_trigger_webhook(@@ -1121,6 +1154,11 @@ def test_delete_menu_item_trigger_webhook("id": menu_item_id,"name": menu_item.name,"menu": {"id": graphene.Node.to_global_id("Menu", menu_item.menu_id)},+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),},WebhookEventAsyncType.MENU_ITEM_DELETED,[any_webhook],diff --git a/saleor/graphql/product/tests/test_category.py b/saleor/graphql/product/tests/test_category.pyindex 8467c718c0..73bc798c1b 100644--- a/saleor/graphql/product/tests/test_category.py+++ b/saleor/graphql/product/tests/test_category.py@@ -5,6 +5,7 @@ import grapheneimport pytestfrom django.utils.functional import SimpleLazyObjectfrom django.utils.text import slugify+from freezegun import freeze_timefrom graphql_relay import to_global_idfrom ....product.error_codes import ProductErrorCode@@ -12,6 +13,7 @@ from ....product.models import Category, Product, ProductChannelListingfrom ....product.tests.utils import create_image, create_pdf_file_with_image_extfrom ....tests.utils import dummy_editorjsfrom ....webhook.event_types import WebhookEventAsyncType+from ....webhook.payloads import generate_meta, generate_requestorfrom ...tests.utils import (get_graphql_content,get_graphql_content_from_response,@@ -446,6 +448,7 @@ def test_category_create_mutation(assert data["category"]["parent"]["id"] == parent_id+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_category_create_trigger_webhook(@@ -498,7 +501,14 @@ def test_category_create_trigger_webhook(assert data["errors"] == []mocked_webhook_trigger.assert_called_once_with(- {"id": graphene.Node.to_global_id("Category", category.id)},+ {+ "id": graphene.Node.to_global_id("Category", category.id),+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CATEGORY_CREATED,[any_webhook],category,@@ -667,6 +677,7 @@ def test_category_update_mutation(assert data["category"]["backgroundImage"]["alt"] == image_alt+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_category_update_trigger_webhook(@@ -718,7 +729,14 @@ def test_category_update_trigger_webhook(assert data["errors"] == []mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"]},+ {+ "id": variables["id"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CATEGORY_UPDATED,[any_webhook],category,@@ -988,6 +1006,7 @@ def test_category_delete_mutation(delete_versatile_image_mock.assert_not_called()+@freeze_time("2022-05-12 12:00:00")@patch("saleor.product.signals.delete_versatile_image")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -1016,7 +1035,14 @@ def test_category_delete_trigger_webhook(delete_versatile_image_mock.assert_not_called()mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"]},+ {+ "id": variables["id"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.CATEGORY_DELETED,[any_webhook],category,diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 3f0908e50a..435ef6e02e 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -20325,9 +20325,72 @@ type Subscription {event: Event}-union Event = AppInstalled | AppUpdated | AppDeleted | AppStatusChanged | CategoryCreated | CategoryUpdated | CategoryDeleted | ChannelCreated | ChannelUpdated | ChannelDeleted | ChannelStatusChanged | GiftCardCreated | GiftCardUpdated | GiftCardDeleted | GiftCardStatusChanged | MenuCreated | MenuUpdated | MenuDeleted | MenuItemCreated | MenuItemUpdated | MenuItemDeleted | OrderCreated | OrderUpdated | OrderConfirmed | OrderFullyPaid | OrderCancelled | OrderFulfilled | DraftOrderCreated | DraftOrderUpdated | DraftOrderDeleted | ProductCreated | ProductUpdated | ProductDeleted | ProductVariantCreated | ProductVariantUpdated | ProductVariantOutOfStock | ProductVariantBackInStock | ProductVariantDeleted | SaleCreated | SaleUpdated | SaleDeleted | InvoiceRequested | InvoiceDeleted | InvoiceSent | FulfillmentCreated | FulfillmentCanceled | CustomerCreated | CustomerUpdated | CollectionCreated | CollectionUpdated | CollectionDeleted | CheckoutCreated | CheckoutUpdated | PageCreated | PageUpdated | PageDeleted | ShippingPriceCreated | ShippingPriceUpdated | ShippingPriceDeleted | ShippingZoneCreated | ShippingZoneUpdated | ShippingZoneDeleted | TransactionActionRequest | TranslationCreated | TranslationUpdated | WarehouseCreated | WarehouseUpdated | WarehouseDeleted | VoucherCreated | VoucherUpdated | VoucherDeleted+interface Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+}++union IssuingPrincipal = App | User++"""An enumeration."""+enum DistanceUnitsEnum {+ CM+ M+ KM+ FT+ YD+ INCH+}++"""An enumeration."""+enum AreaUnitsEnum {+ SQ_CM+ SQ_M+ SQ_KM+ SQ_FT+ SQ_YD+ SQ_INCH+}++"""An enumeration."""+enum VolumeUnitsEnum {+ CUBIC_MILLIMETER+ CUBIC_CENTIMETER+ CUBIC_DECIMETER+ CUBIC_METER+ LITER+ CUBIC_FOOT+ CUBIC_INCH+ CUBIC_YARD+ QT+ PINT+ FL_OZ+ ACRE_IN+ ACRE_FT+}++type AppInstalled implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App-type AppInstalled {"""Look up a app.@@ -20338,7 +20401,19 @@ type AppInstalled {app: App}-type AppUpdated {+type AppUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a app.@@ -20349,7 +20424,19 @@ type AppUpdated {app: App}-type AppDeleted {+type AppDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a app.@@ -20360,7 +20447,19 @@ type AppDeleted {app: App}-type AppStatusChanged {+type AppStatusChanged implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a app.@@ -20371,7 +20470,19 @@ type AppStatusChanged {app: App}-type CategoryCreated {+type CategoryCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a category.@@ -20382,7 +20493,19 @@ type CategoryCreated {category: Category}-type CategoryUpdated {+type CategoryUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a category.@@ -20393,7 +20516,19 @@ type CategoryUpdated {category: Category}-type CategoryDeleted {+type CategoryDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a category.@@ -20404,7 +20539,19 @@ type CategoryDeleted {category: Category}-type ChannelCreated {+type ChannelCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a channel.@@ -20415,7 +20562,19 @@ type ChannelCreated {channel: Channel}-type ChannelUpdated {+type ChannelUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a channel.@@ -20426,7 +20585,19 @@ type ChannelUpdated {channel: Channel}-type ChannelDeleted {+type ChannelDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a channel.@@ -20437,7 +20608,19 @@ type ChannelDeleted {channel: Channel}-type ChannelStatusChanged {+type ChannelStatusChanged implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a channel.@@ -20448,7 +20631,19 @@ type ChannelStatusChanged {channel: Channel}-type GiftCardCreated {+type GiftCardCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a gift card.@@ -20459,7 +20654,19 @@ type GiftCardCreated {giftCard: GiftCard}-type GiftCardUpdated {+type GiftCardUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a gift card.@@ -20470,7 +20677,19 @@ type GiftCardUpdated {giftCard: GiftCard}-type GiftCardDeleted {+type GiftCardDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a gift card.@@ -20481,7 +20700,19 @@ type GiftCardDeleted {giftCard: GiftCard}-type GiftCardStatusChanged {+type GiftCardStatusChanged implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a gift card.@@ -20492,7 +20723,19 @@ type GiftCardStatusChanged {giftCard: GiftCard}-type MenuCreated {+type MenuCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a menu.@@ -20506,7 +20749,19 @@ type MenuCreated {): Menu}-type MenuUpdated {+type MenuUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a menu.@@ -20520,7 +20775,19 @@ type MenuUpdated {): Menu}-type MenuDeleted {+type MenuDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a menu.@@ -20534,7 +20801,19 @@ type MenuDeleted {): Menu}-type MenuItemCreated {+type MenuItemCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a menu item.@@ -20548,7 +20827,19 @@ type MenuItemCreated {): MenuItem}-type MenuItemUpdated {+type MenuItemUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a menu item.@@ -20562,7 +20853,19 @@ type MenuItemUpdated {): MenuItem}-type MenuItemDeleted {+type MenuItemDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a menu item.@@ -20576,7 +20879,19 @@ type MenuItemDeleted {): MenuItem}-type OrderCreated {+type OrderCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20587,7 +20902,19 @@ type OrderCreated {order: Order}-type OrderUpdated {+type OrderUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20598,7 +20925,19 @@ type OrderUpdated {order: Order}-type OrderConfirmed {+type OrderConfirmed implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20609,7 +20948,19 @@ type OrderConfirmed {order: Order}-type OrderFullyPaid {+type OrderFullyPaid implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20620,7 +20971,19 @@ type OrderFullyPaid {order: Order}-type OrderCancelled {+type OrderCancelled implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20631,7 +20994,19 @@ type OrderCancelled {order: Order}-type OrderFulfilled {+type OrderFulfilled implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20642,7 +21017,19 @@ type OrderFulfilled {order: Order}-type DraftOrderCreated {+type DraftOrderCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20653,7 +21040,19 @@ type DraftOrderCreated {order: Order}-type DraftOrderUpdated {+type DraftOrderUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20664,7 +21063,19 @@ type DraftOrderUpdated {order: Order}-type DraftOrderDeleted {+type DraftOrderDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an order.@@ -20675,7 +21086,19 @@ type DraftOrderDeleted {order: Order}-type ProductCreated {+type ProductCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product.@@ -20698,7 +21121,19 @@ type ProductCreated {category: Category}-type ProductUpdated {+type ProductUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product.@@ -20721,7 +21156,19 @@ type ProductUpdated {category: Category}-type ProductDeleted {+type ProductDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product.@@ -20744,7 +21191,19 @@ type ProductDeleted {category: Category}-type ProductVariantCreated {+type ProductVariantCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product variant.@@ -20758,7 +21217,19 @@ type ProductVariantCreated {): ProductVariant}-type ProductVariantUpdated {+type ProductVariantUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product variant.@@ -20772,7 +21243,19 @@ type ProductVariantUpdated {): ProductVariant}-type ProductVariantOutOfStock {+type ProductVariantOutOfStock implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product variant.@@ -20795,7 +21278,19 @@ type ProductVariantOutOfStock {warehouse: Warehouse}-type ProductVariantBackInStock {+type ProductVariantBackInStock implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product variant.@@ -20818,7 +21313,19 @@ type ProductVariantBackInStock {warehouse: Warehouse}-type ProductVariantDeleted {+type ProductVariantDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a product variant.@@ -20832,7 +21339,19 @@ type ProductVariantDeleted {): ProductVariant}-type SaleCreated {+type SaleCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a sale.@@ -20846,7 +21365,19 @@ type SaleCreated {): Sale}-type SaleUpdated {+type SaleUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a sale.@@ -20860,7 +21391,19 @@ type SaleUpdated {): Sale}-type SaleDeleted {+type SaleDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a sale.@@ -20874,7 +21417,19 @@ type SaleDeleted {): Sale}-type InvoiceRequested {+type InvoiceRequested implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an Invoice.@@ -20885,7 +21440,19 @@ type InvoiceRequested {invoice: Invoice}-type InvoiceDeleted {+type InvoiceDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an Invoice.@@ -20896,7 +21463,19 @@ type InvoiceDeleted {invoice: Invoice}-type InvoiceSent {+type InvoiceSent implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up an Invoice.@@ -20907,7 +21486,19 @@ type InvoiceSent {invoice: Invoice}-type FulfillmentCreated {+type FulfillmentCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a Fulfillment.@@ -20918,7 +21509,19 @@ type FulfillmentCreated {fulfillment: Fulfillment}-type FulfillmentCanceled {+type FulfillmentCanceled implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a Fulfillment.@@ -20929,7 +21532,19 @@ type FulfillmentCanceled {fulfillment: Fulfillment}-type CustomerCreated {+type CustomerCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a user.@@ -20940,7 +21555,19 @@ type CustomerCreated {user: User}-type CustomerUpdated {+type CustomerUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a user.@@ -20951,7 +21578,19 @@ type CustomerUpdated {user: User}-type CollectionCreated {+type CollectionCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a collection.@@ -20965,7 +21604,19 @@ type CollectionCreated {): Collection}-type CollectionUpdated {+type CollectionUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a collection.@@ -20979,7 +21630,19 @@ type CollectionUpdated {): Collection}-type CollectionDeleted {+type CollectionDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a collection.@@ -20993,7 +21656,19 @@ type CollectionDeleted {): Collection}-type CheckoutCreated {+type CheckoutCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a Checkout.@@ -21004,7 +21679,19 @@ type CheckoutCreated {checkout: Checkout}-type CheckoutUpdated {+type CheckoutUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a Checkout.@@ -21015,7 +21702,19 @@ type CheckoutUpdated {checkout: Checkout}-type PageCreated {+type PageCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a page.@@ -21026,7 +21725,19 @@ type PageCreated {page: Page}-type PageUpdated {+type PageUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a page.@@ -21037,7 +21748,19 @@ type PageUpdated {page: Page}-type PageDeleted {+type PageDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a page.@@ -21048,7 +21771,19 @@ type PageDeleted {page: Page}-type ShippingPriceCreated {+type ShippingPriceCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a shipping method.@@ -21074,7 +21809,19 @@ type ShippingPriceCreated {): ShippingZone}-type ShippingPriceUpdated {+type ShippingPriceUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a shipping method.@@ -21100,7 +21847,19 @@ type ShippingPriceUpdated {): ShippingZone}-type ShippingPriceDeleted {+type ShippingPriceDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a shipping method.@@ -21126,7 +21885,19 @@ type ShippingPriceDeleted {): ShippingZone}-type ShippingZoneCreated {+type ShippingZoneCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a shipping zone.@@ -21140,7 +21911,19 @@ type ShippingZoneCreated {): ShippingZone}-type ShippingZoneUpdated {+type ShippingZoneUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a shipping zone.@@ -21154,7 +21937,19 @@ type ShippingZoneUpdated {): ShippingZone}-type ShippingZoneDeleted {+type ShippingZoneDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a shipping zone.@@ -21168,7 +21963,19 @@ type ShippingZoneDeleted {): ShippingZone}-type TransactionActionRequest {+type TransactionActionRequest implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a transaction.@@ -21196,7 +22003,19 @@ type TransactionAction {amount: PositiveDecimal}-type TranslationCreated {+type TranslationCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a translation.@@ -21209,7 +22028,19 @@ type TranslationCreated {union TranslationTypes = ProductTranslation | CollectionTranslation | CategoryTranslation | AttributeTranslation | AttributeValueTranslation | ProductVariantTranslation | PageTranslation | ShippingMethodTranslation | SaleTranslation | VoucherTranslation | MenuItemTranslation-type TranslationUpdated {+type TranslationUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a translation.@@ -21220,40 +22051,71 @@ type TranslationUpdated {translation: TranslationTypes}-type WarehouseCreated {- """- Look up a warehouse.-- Added in Saleor 3.4.-- Note: this API is currently in Feature Preview and can be subject to changes at later point.- """- warehouse: Warehouse-}+type VoucherCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App-type WarehouseUpdated {"""- Look up a warehouse.+ Look up a voucher.Added in Saleor 3.4.Note: this API is currently in Feature Preview and can be subject to changes at later point."""- warehouse: Warehouse+ voucher(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): Voucher}-type WarehouseDeleted {+type VoucherUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""- Look up a warehouse.+ Look up a voucher.Added in Saleor 3.4.Note: this API is currently in Feature Preview and can be subject to changes at later point."""- warehouse: Warehouse+ voucher(+ """Slug of a channel for which the data should be returned."""+ channel: String+ ): Voucher}-type VoucherCreated {+type VoucherDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""Look up a voucher.@@ -21267,69 +22129,73 @@ type VoucherCreated {): Voucher}-type VoucherUpdated {+type WarehouseCreated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""- Look up a voucher.+ Look up a warehouse.Added in Saleor 3.4.Note: this API is currently in Feature Preview and can be subject to changes at later point."""- voucher(- """Slug of a channel for which the data should be returned."""- channel: String- ): Voucher+ warehouse: Warehouse}-type VoucherDeleted {+type WarehouseUpdated implements Event {+ """Time of generating the event."""+ issuedAt: DateTime++ """Saleor version."""+ version: String++ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App+"""- Look up a voucher.+ Look up a warehouse.Added in Saleor 3.4.Note: this API is currently in Feature Preview and can be subject to changes at later point."""- voucher(- """Slug of a channel for which the data should be returned."""- channel: String- ): Voucher+ warehouse: Warehouse}-"""An enumeration."""-enum DistanceUnitsEnum {- CM- M- KM- FT- YD- INCH-}+type WarehouseDeleted implements Event {+ """Time of generating the event."""+ issuedAt: DateTime-"""An enumeration."""-enum AreaUnitsEnum {- SQ_CM- SQ_M- SQ_KM- SQ_FT- SQ_YD- SQ_INCH-}+ """Saleor version."""+ version: String-"""An enumeration."""-enum VolumeUnitsEnum {- CUBIC_MILLIMETER- CUBIC_CENTIMETER- CUBIC_DECIMETER- CUBIC_METER- LITER- CUBIC_FOOT- CUBIC_INCH- CUBIC_YARD- QT- PINT- FL_OZ- ACRE_IN- ACRE_FT+ """Look up a issuing principal."""+ issuingPrincipal: IssuingPrincipal++ """Look up a recipient of the webhook."""+ recipient: App++ """+ Look up a warehouse.++ Added in Saleor 3.4.++ Note: this API is currently in Feature Preview and can be subject to changes at later point.+ """+ warehouse: Warehouse}"""_Any value scalar as defined by Federation spec."""diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_method_channel_listing_update.py b/saleor/graphql/shipping/tests/mutations/test_shipping_method_channel_listing_update.pyindex f31a2c454e..cdaeb2b805 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_method_channel_listing_update.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_method_channel_listing_update.py@@ -3,10 +3,12 @@ from unittest.mock import patchimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....shipping.error_codes import ShippingErrorCodefrom .....shipping.models import ShippingMethodChannelListingfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import assert_negative_positive_decimal_value, get_graphql_contentSHIPPING_METHOD_CHANNEL_LISTING_UPDATE_MUTATION = """@@ -103,6 +105,7 @@ def test_shipping_method_channel_listing_create_as_staff_user()+@freeze_time("2022-05-12 12:00:00")@patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_shipping_method_channel_listing_create_trigger_webhook(@@ -156,7 +159,14 @@ def test_shipping_method_channel_listing_create_trigger_webhook(assert data["shippingMethod"]mocked_webhook_trigger.assert_called_once_with(- {"id": shipping_method_id},+ {+ "id": shipping_method_id,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_PRICE_UPDATED,[any_webhook],shipping_method,diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.pyindex 6f61839d7f..92fcf9cbf4 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_create.py@@ -3,11 +3,13 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....shipping.error_codes import ShippingErrorCodefrom .....shipping.models import ShippingMethodfrom .....tests.utils import dummy_editorjsfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....core.enums import WeightUnitsEnumfrom ....tests.utils import get_graphql_contentfrom ...types import PostalCodeRuleInclusionTypeEnum, ShippingMethodTypeEnum@@ -115,6 +117,7 @@ def test_create_shipping_method(assert data["shippingMethod"]["postalCodeRules"] == postal_code_rules+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_create_shipping_method_trigger_webhook(@@ -163,7 +166,14 @@ def test_create_shipping_method_trigger_webhook(assert shipping_methodmocked_webhook_trigger.assert_called_once_with(- {"id": graphene.Node.to_global_id("ShippingMethodType", shipping_method.id)},+ {+ "id": graphene.Node.to_global_id("ShippingMethodType", shipping_method.id),+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_PRICE_CREATED,[any_webhook],shipping_method,diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_delete.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_delete.pyindex 897dbf59a0..c19bdf36d3 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_delete.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_delete.py@@ -2,8 +2,10 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentDELETE_SHIPPING_PRICE_MUTATION = """@@ -49,6 +51,7 @@ def test_delete_shipping_method(assert data["shippingZone"]["id"] == shipping_zone_id+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_delete_shipping_method_trigger_webhook(@@ -81,7 +84,14 @@ def test_delete_shipping_method_trigger_webhook(assert not data["errors"]mocked_webhook_trigger.assert_called_once_with(- {"id": shipping_method_id},+ {+ "id": shipping_method_id,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_PRICE_DELETED,[any_webhook],shipping_method,diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_exclude_products.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_exclude_products.pyindex b452047ca7..94f5622ee9 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_exclude_products.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_exclude_products.py@@ -3,8 +3,10 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentEXCLUDE_PRODUCTS_MUTATION = """@@ -92,6 +94,7 @@ def test_exclude_products_for_shipping_method_already_has_excluded_products(assert excluded_product_ids == set(expected_product_ids)+@freeze_time("2022-05-12 12:00:00")@pytest.mark.parametrize("requestor", ["staff", "app"])@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -123,13 +126,17 @@ def test_exclude_products_for_shipping_method_trigger_webhook(EXCLUDE_PRODUCTS_MUTATION, variables, permissions=[permission_manage_shipping])content = get_graphql_content(response)+ issuer = SimpleLazyObject(lambda: api.user if requestor == "staff" else api.app)# thenassert content["data"]["shippingPriceExcludeProducts"]["shippingMethod"]mocked_webhook_trigger.assert_called_once_with(- {"id": shipping_method_id},+ {+ "id": shipping_method_id,+ "meta": generate_meta(requestor_data=generate_requestor(issuer)),+ },WebhookEventAsyncType.SHIPPING_PRICE_UPDATED,[any_webhook],shipping_method,- SimpleLazyObject(lambda: api.user if requestor == "staff" else api.app),+ issuer,)diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_remove_product_from_exclude.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_remove_product_from_exclude.pyindex 05b16d85be..1af0cc15d0 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_remove_product_from_exclude.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_remove_product_from_exclude.py@@ -3,8 +3,10 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentREMOVE_PRODUCTS_FROM_EXCLUDED_PRODUCTS_MUTATION = """@@ -109,6 +111,7 @@ def test_remove_products_from_excluded_products_for_shipping_method(assert excluded_product_ids == expected_product_ids+@freeze_time("2022-05-12 12:00:00")@pytest.mark.parametrize("requestor", ["staff", "app"])@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")@@ -148,13 +151,17 @@ def test_remove_products_from_excluded_products_for_shipping_method_trigger_webhpermissions=[permission_manage_shipping],)content = get_graphql_content(response)+ issuer = SimpleLazyObject(lambda: api.user if requestor == "staff" else api.app)# thenassert content["data"]["shippingPriceRemoveProductFromExclude"]["shippingMethod"]mocked_webhook_trigger.assert_called_once_with(- {"id": shipping_method_id},+ {+ "id": shipping_method_id,+ "meta": generate_meta(requestor_data=generate_requestor(issuer)),+ },WebhookEventAsyncType.SHIPPING_PRICE_UPDATED,[any_webhook],shipping_method,- SimpleLazyObject(lambda: api.user if requestor == "staff" else api.app),+ issuer,)diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py b/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.pyindex 6569971bf7..87e684f145 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_price_update.py@@ -3,10 +3,12 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....shipping.error_codes import ShippingErrorCodefrom .....tests.utils import dummy_editorjsfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....core.enums import WeightUnitsEnumfrom ....tests.utils import get_graphql_contentfrom ...types import PostalCodeRuleInclusionTypeEnum, ShippingMethodTypeEnum@@ -91,6 +93,7 @@ def test_update_shipping_method(assert data["shippingMethod"]["maximumDeliveryDays"] == max_del_days+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_update_shipping_method_trigger_webhook(@@ -136,7 +139,14 @@ def test_update_shipping_method_trigger_webhook(assert not data["errors"]mocked_webhook_trigger.assert_called_once_with(- {"id": shipping_method_id},+ {+ "id": shipping_method_id,+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_PRICE_UPDATED,[any_webhook],shipping_method,diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_zone_create.py b/saleor/graphql/shipping/tests/mutations/test_shipping_zone_create.pyindex 9e3f2dd6f9..8a59b75f12 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_zone_create.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_zone_create.py@@ -2,10 +2,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....shipping.error_codes import ShippingErrorCodefrom .....shipping.models import ShippingZonefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentCREATE_SHIPPING_ZONE_MUTATION = """@@ -84,6 +86,7 @@ def test_create_shipping_zone(assert zone["default"] is False+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_create_shipping_zone_trigger_webhook(@@ -126,7 +129,14 @@ def test_create_shipping_zone_trigger_webhook(assert data["errors"] == []mocked_webhook_trigger.assert_called_once_with(- {"id": data["shippingZone"]["id"]},+ {+ "id": data["shippingZone"]["id"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_ZONE_CREATED,[any_webhook],shipping_zone,diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_zone_delete.py b/saleor/graphql/shipping/tests/mutations/test_shipping_zone_delete.pyindex f5720a9788..aceb778ba0 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_zone_delete.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_zone_delete.py@@ -3,8 +3,10 @@ from unittest import mockimport grapheneimport pytestfrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentDELETE_SHIPPING_ZONE_MUTATION = """@@ -46,6 +48,7 @@ def test_delete_shipping_zone(shipping_zone.refresh_from_db()+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_delete_shipping_zone_trigger_webhook(@@ -78,7 +81,14 @@ def test_delete_shipping_zone_trigger_webhook(assert data["errors"] == []mocked_webhook_trigger.assert_called_once_with(- {"id": data["shippingZone"]["id"]},+ {+ "id": data["shippingZone"]["id"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_ZONE_DELETED,[any_webhook],shipping_zone,diff --git a/saleor/graphql/shipping/tests/mutations/test_shipping_zone_update.py b/saleor/graphql/shipping/tests/mutations/test_shipping_zone_update.pyindex 4db93f81b4..d175c55c85 100644--- a/saleor/graphql/shipping/tests/mutations/test_shipping_zone_update.py+++ b/saleor/graphql/shipping/tests/mutations/test_shipping_zone_update.py@@ -2,10 +2,12 @@ from unittest import mockimport graphenefrom django.utils.functional import SimpleLazyObject+from freezegun import freeze_timefrom .....shipping.error_codes import ShippingErrorCodefrom .....shipping.models import ShippingMethodChannelListingfrom .....webhook.event_types import WebhookEventAsyncType+from .....webhook.payloads import generate_meta, generate_requestorfrom ....tests.utils import get_graphql_contentUPDATE_SHIPPING_ZONE_MUTATION = """@@ -81,6 +83,7 @@ def test_update_shipping_zone(assert data["description"] == description+@freeze_time("2022-05-12 12:00:00")@mock.patch("saleor.plugins.webhook.plugin.get_webhooks_for_event")@mock.patch("saleor.plugins.webhook.plugin.trigger_webhooks_async")def test_update_shipping_zone_trigger_webhook(@@ -116,7 +119,14 @@ def test_update_shipping_zone_trigger_webhook(assert data["shippingZone"]mocked_webhook_trigger.assert_called_once_with(- {"id": variables["id"]},+ {+ "id": variables["id"],+ "meta": generate_meta(+ requestor_data=generate_requestor(+ SimpleLazyObject(lambda: staff_api_client.user)+ )+ ),+ },WebhookEventAsyncType.SHIPPING_ZONE_UPDATED,[any_webhook],shipping_zone,diff --git a/saleor/graphql/tests/queries/fragments.py b/saleor/graphql/tests/queries/fragments.pyindex e32c85fbef..45ccdee570 100644--- a/saleor/graphql/tests/queries/fragments.py+++ b/saleor/graphql/tests/queries/fragments.py@@ -1,3 +1,12 @@+APP_DETAILS = """+ fragment AppDetails on App{+ id+ isActive+ name+ appUrl+ }+"""+PRICE = """fragment Price on TaxedMoney {currency@@ -326,3 +335,29 @@ fragment VoucherDetails on Voucher{usageLimit}"""+++MENU_DETAILS = """+ fragment MenuDetails on Menu{+ id+ name+ slug+ items {+ id+ name+ }+ }+"""++MENU_ITEM_DETAILS = """+ fragment MenuItemDetails on MenuItem{+ id+ name+ menu {+ id+ }+ page {+ id+ }+ }+"""diff --git a/saleor/graphql/webhook/subscription_payload.py b/saleor/graphql/webhook/subscription_payload.pyindex b72022ec87..e0290ff2ee 100644--- a/saleor/graphql/webhook/subscription_payload.py+++ b/saleor/graphql/webhook/subscription_payload.py@@ -48,7 +48,7 @@ def check_document_is_single_subscription(document: GraphQLDocument) -> bool:return len(subscriptions) == 1-def initialize_context() -> HttpRequest:+def initialize_context(requestor=None) -> HttpRequest:"""Prepare a request object for webhook subscription.It creates a dummy request object and initialize middleware on it. It is required@@ -57,6 +57,7 @@ def initialize_context() -> HttpRequest:"""handler = BaseHandler()context = RequestFactory().request(SERVER_NAME=SimpleLazyObject(get_host))+ context.requestor = requestor # type: ignorehandler.load_middleware()response = handler.get_response(context)if not response.status_code == 200:@@ -77,7 +78,7 @@ def generate_payload_from_subscription(As an input it expects given event type and object and the query which will beused to resolve a payload.event_type: is a event which will be triggered.- subscribable_object: is a object which have a dedicated own type in Subscription+ subscribable_object: is an object which have a dedicated own type in Subscriptiondefinition.subscription_query: query used to prepare a payload via graphql engine.context: A dummy request used to share context between apps in order to usediff --git a/saleor/graphql/webhook/subscription_types.py b/saleor/graphql/webhook/subscription_types.pyindex b3cb02a80c..72ceb035bc 100644--- a/saleor/graphql/webhook/subscription_types.py+++ b/saleor/graphql/webhook/subscription_types.py@@ -1,7 +1,11 @@import graphene+from django.contrib.auth.models import AnonymousUser+from django.utils import timezonefrom graphene import AbstractType, ObjectType, Unionfrom rx import Observable+from ... import __version__+from ...account.models import Userfrom ...attribute.models import AttributeTranslation, AttributeValueTranslationfrom ...core.prices import quantize_pricefrom ...discount.models import SaleTranslation, VoucherTranslation@@ -16,6 +20,8 @@ from ...product.models import ()from ...shipping.models import ShippingMethodTranslationfrom ...webhook.event_types import WebhookEventAsyncType+from ..account.types import User as UserType+from ..app.types import App as AppTypefrom ..channel import ChannelContextfrom ..core.descriptions import ADDED_IN_32, ADDED_IN_34, PREVIEW_FEATUREfrom ..core.scalars import PositiveDecimal@@ -38,6 +44,133 @@ TRANSLATIONS_TYPES_MAP = {}+class IssuingPrincipal(Union):+ class Meta:+ types = (AppType, UserType)++ @classmethod+ def resolve_type(cls, instance, info):+ if isinstance(instance, User):+ return UserType+ return AppType+++class Event(graphene.Interface):+ issued_at = graphene.DateTime(description="Time of generating the event.")+ version = graphene.String(description="Saleor version.")+ issuing_principal = graphene.Field(+ IssuingPrincipal, description="Look up a issuing principal."+ )+ recipient = graphene.Field(+ "saleor.graphql.app.types.App",+ description="Look up a recipient of the webhook.",+ )++ @classmethod+ def get_type(cls, object_type: str):+ types = {+ WebhookEventAsyncType.APP_INSTALLED: AppInstalled,+ WebhookEventAsyncType.APP_UPDATED: AppUpdated,+ WebhookEventAsyncType.APP_DELETED: AppDeleted,+ WebhookEventAsyncType.APP_STATUS_CHANGED: AppStatusChanged,+ WebhookEventAsyncType.CATEGORY_CREATED: CategoryCreated,+ WebhookEventAsyncType.CATEGORY_UPDATED: CategoryUpdated,+ WebhookEventAsyncType.CATEGORY_DELETED: CategoryDeleted,+ WebhookEventAsyncType.CHANNEL_CREATED: ChannelCreated,+ WebhookEventAsyncType.CHANNEL_UPDATED: ChannelUpdated,+ WebhookEventAsyncType.CHANNEL_DELETED: ChannelDeleted,+ WebhookEventAsyncType.CHANNEL_STATUS_CHANGED: ChannelStatusChanged,+ WebhookEventAsyncType.GIFT_CARD_CREATED: GiftCardCreated,+ WebhookEventAsyncType.GIFT_CARD_UPDATED: GiftCardUpdated,+ WebhookEventAsyncType.GIFT_CARD_DELETED: GiftCardDeleted,+ WebhookEventAsyncType.GIFT_CARD_STATUS_CHANGED: GiftCardStatusChanged,+ WebhookEventAsyncType.MENU_CREATED: MenuCreated,+ WebhookEventAsyncType.MENU_UPDATED: MenuUpdated,+ WebhookEventAsyncType.MENU_DELETED: MenuDeleted,+ WebhookEventAsyncType.MENU_ITEM_CREATED: MenuItemCreated,+ WebhookEventAsyncType.MENU_ITEM_UPDATED: MenuItemUpdated,+ WebhookEventAsyncType.MENU_ITEM_DELETED: MenuItemDeleted,+ WebhookEventAsyncType.ORDER_CREATED: OrderCreated,+ WebhookEventAsyncType.ORDER_UPDATED: OrderUpdated,+ WebhookEventAsyncType.ORDER_CONFIRMED: OrderConfirmed,+ WebhookEventAsyncType.ORDER_FULLY_PAID: OrderFullyPaid,+ WebhookEventAsyncType.ORDER_FULFILLED: OrderFulfilled,+ WebhookEventAsyncType.ORDER_CANCELLED: OrderCancelled,+ WebhookEventAsyncType.DRAFT_ORDER_CREATED: DraftOrderCreated,+ WebhookEventAsyncType.DRAFT_ORDER_UPDATED: DraftOrderUpdated,+ WebhookEventAsyncType.DRAFT_ORDER_DELETED: DraftOrderDeleted,+ WebhookEventAsyncType.PRODUCT_CREATED: ProductCreated,+ WebhookEventAsyncType.PRODUCT_UPDATED: ProductUpdated,+ WebhookEventAsyncType.PRODUCT_DELETED: ProductDeleted,+ WebhookEventAsyncType.PRODUCT_VARIANT_CREATED: ProductVariantCreated,+ WebhookEventAsyncType.PRODUCT_VARIANT_UPDATED: ProductVariantUpdated,+ WebhookEventAsyncType.PRODUCT_VARIANT_OUT_OF_STOCK: (+ ProductVariantOutOfStock+ ),+ WebhookEventAsyncType.PRODUCT_VARIANT_BACK_IN_STOCK: (+ ProductVariantBackInStock+ ),+ WebhookEventAsyncType.PRODUCT_VARIANT_DELETED: ProductVariantDeleted,+ WebhookEventAsyncType.SALE_CREATED: SaleCreated,+ WebhookEventAsyncType.SALE_UPDATED: SaleUpdated,+ WebhookEventAsyncType.SALE_DELETED: SaleDeleted,+ WebhookEventAsyncType.INVOICE_REQUESTED: InvoiceRequested,+ WebhookEventAsyncType.INVOICE_DELETED: InvoiceDeleted,+ WebhookEventAsyncType.INVOICE_SENT: InvoiceSent,+ WebhookEventAsyncType.FULFILLMENT_CREATED: FulfillmentCreated,+ WebhookEventAsyncType.FULFILLMENT_CANCELED: FulfillmentCanceled,+ WebhookEventAsyncType.CUSTOMER_CREATED: CustomerCreated,+ WebhookEventAsyncType.CUSTOMER_UPDATED: CustomerUpdated,+ WebhookEventAsyncType.COLLECTION_CREATED: CollectionCreated,+ WebhookEventAsyncType.COLLECTION_UPDATED: CollectionUpdated,+ WebhookEventAsyncType.COLLECTION_DELETED: CollectionDeleted,+ WebhookEventAsyncType.CHECKOUT_CREATED: CheckoutCreated,+ WebhookEventAsyncType.CHECKOUT_UPDATED: CheckoutUpdated,+ WebhookEventAsyncType.PAGE_CREATED: PageCreated,+ WebhookEventAsyncType.PAGE_UPDATED: PageUpdated,+ WebhookEventAsyncType.PAGE_DELETED: PageDeleted,+ WebhookEventAsyncType.SHIPPING_PRICE_CREATED: ShippingPriceCreated,+ WebhookEventAsyncType.SHIPPING_PRICE_UPDATED: ShippingPriceUpdated,+ WebhookEventAsyncType.SHIPPING_PRICE_DELETED: ShippingPriceDeleted,+ WebhookEventAsyncType.SHIPPING_ZONE_CREATED: ShippingZoneCreated,+ WebhookEventAsyncType.SHIPPING_ZONE_UPDATED: ShippingZoneUpdated,+ WebhookEventAsyncType.SHIPPING_ZONE_DELETED: ShippingZoneDeleted,+ WebhookEventAsyncType.TRANSACTION_ACTION_REQUEST: TransactionActionRequest,+ WebhookEventAsyncType.TRANSLATION_CREATED: TranslationCreated,+ WebhookEventAsyncType.TRANSLATION_UPDATED: TranslationUpdated,+ WebhookEventAsyncType.VOUCHER_CREATED: VoucherCreated,+ WebhookEventAsyncType.VOUCHER_UPDATED: VoucherUpdated,+ WebhookEventAsyncType.VOUCHER_DELETED: VoucherDeleted,+ WebhookEventAsyncType.WAREHOUSE_CREATED: WarehouseCreated,+ WebhookEventAsyncType.WAREHOUSE_UPDATED: WarehouseUpdated,+ WebhookEventAsyncType.WAREHOUSE_DELETED: WarehouseDeleted,+ }+ return types.get(object_type)++ @classmethod+ def resolve_type(cls, instance, info):+ type_str, _ = instance+ return cls.get_type(type_str)++ @staticmethod+ def resolve_issued_at(_root, _info):+ return timezone.now()++ @staticmethod+ def resolve_version(_root, _info):+ return __version__++ @staticmethod+ def resolve_recipient(_root, info):+ return info.context.app++ @staticmethod+ def resolve_issuing_principal(_root, info):+ if isinstance(info.context.requestor, AnonymousUser):+ return None+ return info.context.requestor++class AppBase(AbstractType):app = graphene.Field("saleor.graphql.app.types.App",@@ -51,19 +184,23 @@ class AppBase(AbstractType):class AppInstalled(ObjectType, AppBase):- ...+ class Meta:+ interfaces = (Event,)class AppUpdated(ObjectType, AppBase):- ...+ class Meta:+ interfaces = (Event,)class AppDeleted(ObjectType, AppBase):- ...+ class Meta:+ interfaces = (Event,)class AppStatusChanged(ObjectType, AppBase):- ...+ class Meta:+ interfaces = (Event,)class CategoryBase(AbstractType):@@ -79,15 +216,18 @@ class CategoryBase(AbstractType):class CategoryCreated(ObjectType, CategoryBase):- ...+ class Meta:+ interfaces = (Event,)class CategoryUpdated(ObjectType, CategoryBase):- ...+ class Meta:+ interfaces = (Event,)class CategoryDeleted(ObjectType, CategoryBase):- ...+ class Meta:+ interfaces = (Event,)class ChannelBase(AbstractType):@@ -103,19 +243,23 @@ class ChannelBase(AbstractType):class ChannelCreated(ObjectType, ChannelBase):- ...+ class Meta:+ interfaces = (Event,)class ChannelUpdated(ObjectType, ChannelBase):- ...+ class Meta:+ interfaces = (Event,)class ChannelDeleted(ObjectType, ChannelBase):- ...+ class Meta:+ interfaces = (Event,)class ChannelStatusChanged(ObjectType, ChannelBase):- ...+ class Meta:+ interfaces = (Event,)class OrderBase(AbstractType):@@ -131,39 +275,48 @@ class OrderBase(AbstractType):class OrderCreated(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class OrderUpdated(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class OrderConfirmed(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class OrderFullyPaid(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class OrderFulfilled(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class OrderCancelled(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class DraftOrderCreated(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class DraftOrderUpdated(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class DraftOrderDeleted(ObjectType, OrderBase):- ...+ class Meta:+ interfaces = (Event,)class GiftCardBase(AbstractType):@@ -179,19 +332,23 @@ class GiftCardBase(AbstractType):class GiftCardCreated(ObjectType, GiftCardBase):- ...+ class Meta:+ interfaces = (Event,)class GiftCardUpdated(ObjectType, GiftCardBase):- ...+ class Meta:+ interfaces = (Event,)class GiftCardDeleted(ObjectType, GiftCardBase):- ...+ class Meta:+ interfaces = (Event,)class GiftCardStatusChanged(ObjectType, GiftCardBase):- ...+ class Meta:+ interfaces = (Event,)class MenuBase(AbstractType):@@ -210,15 +367,18 @@ class MenuBase(AbstractType):class MenuCreated(ObjectType, MenuBase):- ...+ class Meta:+ interfaces = (Event,)class MenuUpdated(ObjectType, MenuBase):- ...+ class Meta:+ interfaces = (Event,)class MenuDeleted(ObjectType, MenuBase):- ...+ class Meta:+ interfaces = (Event,)class MenuItemBase(AbstractType):@@ -237,15 +397,18 @@ class MenuItemBase(AbstractType):class MenuItemCreated(ObjectType, MenuItemBase):- ...+ class Meta:+ interfaces = (Event,)class MenuItemUpdated(ObjectType, MenuItemBase):- ...+ class Meta:+ interfaces = (Event,)class MenuItemDeleted(ObjectType, MenuItemBase):- ...+ class Meta:+ interfaces = (Event,)class ProductBase(AbstractType):@@ -273,15 +436,18 @@ class ProductBase(AbstractType):class ProductCreated(ObjectType, ProductBase):- ...+ class Meta:+ interfaces = (Event,)class ProductUpdated(ObjectType, ProductBase):- ...+ class Meta:+ interfaces = (Event,)class ProductDeleted(ObjectType, ProductBase):- ...+ class Meta:+ interfaces = (Event,)class ProductVariantBase(AbstractType):@@ -300,15 +466,18 @@ class ProductVariantBase(AbstractType):class ProductVariantCreated(ObjectType, ProductVariantBase):- ...+ class Meta:+ interfaces = (Event,)class ProductVariantUpdated(ObjectType, ProductVariantBase):- ...+ class Meta:+ interfaces = (Event,)class ProductVariantDeleted(ObjectType, ProductVariantBase):- ...+ class Meta:+ interfaces = (Event,)class ProductVariantOutOfStock(ObjectType, ProductVariantBase):@@ -317,6 +486,9 @@ class ProductVariantOutOfStock(ObjectType, ProductVariantBase):description="Look up a warehouse." + ADDED_IN_32 + PREVIEW_FEATURE,)+ class Meta:+ interfaces = (Event,)+@staticmethoddef resolve_product_variant(root, info, channel=None):_, stock = root@@ -335,6 +507,9 @@ class ProductVariantBackInStock(ObjectType, ProductVariantBase):description="Look up a warehouse." + ADDED_IN_32 + PREVIEW_FEATURE,)+ class Meta:+ interfaces = (Event,)+@staticmethoddef resolve_product_variant(root, _info, channel=None):_, stock = root@@ -363,15 +538,18 @@ class SaleBase(AbstractType):class SaleCreated(ObjectType, SaleBase):- ...+ class Meta:+ interfaces = (Event,)class SaleUpdated(ObjectType, SaleBase):- ...+ class Meta:+ interfaces = (Event,)class SaleDeleted(ObjectType, SaleBase):- ...+ class Meta:+ interfaces = (Event,)class InvoiceBase(AbstractType):@@ -387,15 +565,18 @@ class InvoiceBase(AbstractType):class InvoiceRequested(ObjectType, InvoiceBase):- ...+ class Meta:+ interfaces = (Event,)class InvoiceDeleted(ObjectType, InvoiceBase):- ...+ class Meta:+ interfaces = (Event,)class InvoiceSent(ObjectType, InvoiceBase):- ...+ class Meta:+ interfaces = (Event,)class FulfillmentBase(AbstractType):@@ -411,11 +592,13 @@ class FulfillmentBase(AbstractType):class FulfillmentCreated(ObjectType, FulfillmentBase):- ...+ class Meta:+ interfaces = (Event,)class FulfillmentCanceled(ObjectType, FulfillmentBase):- ...+ class Meta:+ interfaces = (Event,)class UserBase(AbstractType):@@ -431,11 +614,13 @@ class UserBase(AbstractType):class CustomerCreated(ObjectType, UserBase):- ...+ class Meta:+ interfaces = (Event,)class CustomerUpdated(ObjectType, UserBase):- ...+ class Meta:+ interfaces = (Event,)class CollectionBase(AbstractType):@@ -454,15 +639,18 @@ class CollectionBase(AbstractType):class CollectionCreated(ObjectType, CollectionBase):- ...+ class Meta:+ interfaces = (Event,)class CollectionUpdated(ObjectType, CollectionBase):- ...+ class Meta:+ interfaces = (Event,)class CollectionDeleted(ObjectType, CollectionBase):- ...+ class Meta:+ interfaces = (Event,)class CheckoutBase(AbstractType):@@ -478,11 +666,13 @@ class CheckoutBase(AbstractType):class CheckoutCreated(ObjectType, CheckoutBase):- ...+ class Meta:+ interfaces = (Event,)class CheckoutUpdated(ObjectType, CheckoutBase):- ...+ class Meta:+ interfaces = (Event,)class PageBase(AbstractType):@@ -498,15 +688,18 @@ class PageBase(AbstractType):class PageCreated(ObjectType, PageBase):- ...+ class Meta:+ interfaces = (Event,)class PageUpdated(ObjectType, PageBase):- ...+ class Meta:+ interfaces = (Event,)class PageDeleted(ObjectType, PageBase):- ...+ class Meta:+ interfaces = (Event,)class ShippingPriceBase(AbstractType):@@ -537,15 +730,18 @@ class ShippingPriceBase(AbstractType):class ShippingPriceCreated(ObjectType, ShippingPriceBase):- ...+ class Meta:+ interfaces = (Event,)class ShippingPriceUpdated(ObjectType, ShippingPriceBase):- ...+ class Meta:+ interfaces = (Event,)class ShippingPriceDeleted(ObjectType, ShippingPriceBase):- ...+ class Meta:+ interfaces = (Event,)class ShippingZoneBase(AbstractType):@@ -564,18 +760,21 @@ class ShippingZoneBase(AbstractType):class ShippingZoneCreated(ObjectType, ShippingZoneBase):- ...+ class Meta:+ interfaces = (Event,)class ShippingZoneUpdated(ObjectType, ShippingZoneBase):- ...+ class Meta:+ interfaces = (Event,)class ShippingZoneDeleted(ObjectType, ShippingZoneBase):- ...+ class Meta:+ interfaces = (Event,)-class TransactionAction(ObjectType):+class TransactionAction(ObjectType, AbstractType):action_type = graphene.Field(TransactionActionEnum,required=True,@@ -603,6 +802,9 @@ class TransactionActionRequest(ObjectType):description="Requested action data." + ADDED_IN_34 + PREVIEW_FEATURE,)+ class Meta:+ interfaces = (Event,)+@staticmethoddef resolve_transaction(root, _info):_, transaction_action_data = root@@ -642,35 +844,13 @@ class TranslationBase(AbstractType):class TranslationCreated(ObjectType, TranslationBase):- ...+ class Meta:+ interfaces = (Event,)class TranslationUpdated(ObjectType, TranslationBase):- ...---class WarehouseBase(AbstractType):- warehouse = graphene.Field(- "saleor.graphql.warehouse.types.Warehouse",- description="Look up a warehouse." + ADDED_IN_34 + PREVIEW_FEATURE,- )-- @staticmethod- def resolve_warehouse(root, _info):- _, warehouse = root- return warehouse---class WarehouseCreated(ObjectType, WarehouseBase):- ...---class WarehouseUpdated(ObjectType, WarehouseBase):- ...---class WarehouseDeleted(ObjectType, WarehouseBase):- ...+ class Meta:+ interfaces = (Event,)class VoucherBase(AbstractType):@@ -689,178 +869,45 @@ class VoucherBase(AbstractType):class VoucherCreated(ObjectType, VoucherBase):- ...+ class Meta:+ interfaces = (Event,)class VoucherUpdated(ObjectType, VoucherBase):- ...+ class Meta:+ interfaces = (Event,)class VoucherDeleted(ObjectType, VoucherBase):- ...---class Event(Union):- class Meta:- types = (- AppInstalled,- AppUpdated,- AppDeleted,- AppStatusChanged,- CategoryCreated,- CategoryUpdated,- CategoryDeleted,- ChannelCreated,- ChannelUpdated,- ChannelDeleted,- ChannelStatusChanged,- GiftCardCreated,- GiftCardUpdated,- GiftCardDeleted,- GiftCardStatusChanged,- MenuCreated,- MenuUpdated,- MenuDeleted,- MenuItemCreated,- MenuItemUpdated,- MenuItemDeleted,- OrderCreated,- OrderUpdated,- OrderConfirmed,- OrderFullyPaid,- OrderCancelled,- OrderFulfilled,- DraftOrderCreated,- DraftOrderUpdated,- DraftOrderDeleted,- ProductCreated,- ProductUpdated,- ProductDeleted,- ProductVariantCreated,- ProductVariantUpdated,- ProductVariantOutOfStock,- ProductVariantBackInStock,- ProductVariantDeleted,- SaleCreated,- SaleUpdated,- SaleDeleted,- InvoiceRequested,- InvoiceDeleted,- InvoiceSent,- FulfillmentCreated,- FulfillmentCanceled,- CustomerCreated,- CustomerUpdated,- CollectionCreated,- CollectionUpdated,- CollectionDeleted,- CheckoutCreated,- CheckoutUpdated,- PageCreated,- PageUpdated,- PageDeleted,- ShippingPriceCreated,- ShippingPriceUpdated,- ShippingPriceDeleted,- ShippingZoneCreated,- ShippingZoneUpdated,- ShippingZoneDeleted,- TransactionActionRequest,- TranslationCreated,- TranslationUpdated,- WarehouseCreated,- WarehouseUpdated,- WarehouseDeleted,- VoucherCreated,- VoucherUpdated,- VoucherDeleted,- )+ class Meta:+ interfaces = (Event,)- @classmethod- def get_type(cls, object_type: str):- types = {- WebhookEventAsyncType.APP_INSTALLED: AppInstalled,- WebhookEventAsyncType.APP_UPDATED: AppUpdated,- WebhookEventAsyncType.APP_DELETED: AppDeleted,- WebhookEventAsyncType.APP_STATUS_CHANGED: AppStatusChanged,- WebhookEventAsyncType.CATEGORY_CREATED: CategoryCreated,- WebhookEventAsyncType.CATEGORY_UPDATED: CategoryUpdated,- WebhookEventAsyncType.CATEGORY_DELETED: CategoryDeleted,- WebhookEventAsyncType.CHANNEL_CREATED: ChannelCreated,- WebhookEventAsyncType.CHANNEL_UPDATED: ChannelUpdated,- WebhookEventAsyncType.CHANNEL_DELETED: ChannelDeleted,- WebhookEventAsyncType.CHANNEL_STATUS_CHANGED: ChannelStatusChanged,- WebhookEventAsyncType.GIFT_CARD_CREATED: GiftCardCreated,- WebhookEventAsyncType.GIFT_CARD_UPDATED: GiftCardUpdated,- WebhookEventAsyncType.GIFT_CARD_DELETED: GiftCardDeleted,- WebhookEventAsyncType.GIFT_CARD_STATUS_CHANGED: GiftCardStatusChanged,- WebhookEventAsyncType.MENU_CREATED: MenuCreated,- WebhookEventAsyncType.MENU_UPDATED: MenuUpdated,- WebhookEventAsyncType.MENU_DELETED: MenuDeleted,- WebhookEventAsyncType.MENU_ITEM_CREATED: MenuItemCreated,- WebhookEventAsyncType.MENU_ITEM_UPDATED: MenuItemUpdated,- WebhookEventAsyncType.MENU_ITEM_DELETED: MenuItemDeleted,- WebhookEventAsyncType.ORDER_CREATED: OrderCreated,- WebhookEventAsyncType.ORDER_UPDATED: OrderUpdated,- WebhookEventAsyncType.ORDER_CONFIRMED: OrderConfirmed,- WebhookEventAsyncType.ORDER_FULLY_PAID: OrderFullyPaid,- WebhookEventAsyncType.ORDER_FULFILLED: OrderFulfilled,- WebhookEventAsyncType.ORDER_CANCELLED: OrderCancelled,- WebhookEventAsyncType.DRAFT_ORDER_CREATED: DraftOrderCreated,- WebhookEventAsyncType.DRAFT_ORDER_UPDATED: DraftOrderUpdated,- WebhookEventAsyncType.DRAFT_ORDER_DELETED: DraftOrderDeleted,- WebhookEventAsyncType.PRODUCT_CREATED: ProductCreated,- WebhookEventAsyncType.PRODUCT_UPDATED: ProductUpdated,- WebhookEventAsyncType.PRODUCT_DELETED: ProductDeleted,- WebhookEventAsyncType.PRODUCT_VARIANT_CREATED: ProductVariantCreated,- WebhookEventAsyncType.PRODUCT_VARIANT_UPDATED: ProductVariantUpdated,- WebhookEventAsyncType.PRODUCT_VARIANT_OUT_OF_STOCK: (- ProductVariantOutOfStock- ),- WebhookEventAsyncType.PRODUCT_VARIANT_BACK_IN_STOCK: (- ProductVariantBackInStock- ),- WebhookEventAsyncType.PRODUCT_VARIANT_DELETED: ProductVariantDeleted,- WebhookEventAsyncType.SALE_CREATED: SaleCreated,- WebhookEventAsyncType.SALE_UPDATED: SaleUpdated,- WebhookEventAsyncType.SALE_DELETED: SaleDeleted,- WebhookEventAsyncType.INVOICE_REQUESTED: InvoiceRequested,- WebhookEventAsyncType.INVOICE_DELETED: InvoiceDeleted,- WebhookEventAsyncType.INVOICE_SENT: InvoiceSent,- WebhookEventAsyncType.FULFILLMENT_CREATED: FulfillmentCreated,- WebhookEventAsyncType.FULFILLMENT_CANCELED: FulfillmentCanceled,- WebhookEventAsyncType.CUSTOMER_CREATED: CustomerCreated,- WebhookEventAsyncType.CUSTOMER_UPDATED: CustomerUpdated,- WebhookEventAsyncType.COLLECTION_CREATED: CollectionCreated,- WebhookEventAsyncType.COLLECTION_UPDATED: CollectionUpdated,- WebhookEventAsyncType.COLLECTION_DELETED: CollectionDeleted,- WebhookEventAsyncType.CHECKOUT_CREATED: CheckoutCreated,- WebhookEventAsyncType.CHECKOUT_UPDATED: CheckoutUpdated,- WebhookEventAsyncType.PAGE_CREATED: PageCreated,- WebhookEventAsyncType.PAGE_UPDATED: PageUpdated,- WebhookEventAsyncType.PAGE_DELETED: PageDeleted,- WebhookEventAsyncType.SHIPPING_PRICE_CREATED: ShippingPriceCreated,- WebhookEventAsyncType.SHIPPING_PRICE_UPDATED: ShippingPriceUpdated,- WebhookEventAsyncType.SHIPPING_PRICE_DELETED: ShippingPriceDeleted,- WebhookEventAsyncType.SHIPPING_ZONE_CREATED: ShippingZoneCreated,- WebhookEventAsyncType.SHIPPING_ZONE_UPDATED: ShippingZoneUpdated,- WebhookEventAsyncType.SHIPPING_ZONE_DELETED: ShippingZoneDeleted,- WebhookEventAsyncType.TRANSACTION_ACTION_REQUEST: TransactionActionRequest,- WebhookEventAsyncType.TRANSLATION_CREATED: TranslationCreated,- WebhookEventAsyncType.TRANSLATION_UPDATED: TranslationUpdated,- WebhookEventAsyncType.WAREHOUSE_CREATED: WarehouseCreated,- WebhookEventAsyncType.WAREHOUSE_UPDATED: WarehouseUpdated,- WebhookEventAsyncType.WAREHOUSE_DELETED: WarehouseDeleted,- WebhookEventAsyncType.VOUCHER_CREATED: VoucherCreated,- WebhookEventAsyncType.VOUCHER_UPDATED: VoucherUpdated,- WebhookEventAsyncType.VOUCHER_DELETED: VoucherDeleted,- }- return types.get(object_type)- @classmethod- def resolve_type(cls, instance, info):- type_str, _ = instance- return cls.get_type(type_str)+class WarehouseBase(AbstractType):+ warehouse = graphene.Field(+ "saleor.graphql.warehouse.types.Warehouse",+ description="Look up a warehouse." + ADDED_IN_34 + PREVIEW_FEATURE,+ )++ @staticmethod+ def resolve_warehouse(root, _info):+ _, warehouse = root+ return warehouse+++class WarehouseCreated(ObjectType, WarehouseBase):+ class Meta:+ interfaces = (Event,)+++class WarehouseUpdated(ObjectType, WarehouseBase):+ class Meta:+ interfaces = (Event,)+++class WarehouseDeleted(ObjectType, WarehouseBase):+ class Meta:+ interfaces = (Event,)class Subscription(ObjectType):@@ -872,3 +919,81 @@ class Subscription(ObjectType):@staticmethoddef resolve_event(root, info):return Observable.from_([root])+++# List of events is created because `Event` type was change from `Union` to `Interface`+# so all subscription events types need to be added manually to `Schema`.++SUBSCRIPTION_EVENTS_TYPES = [+ AppInstalled,+ AppUpdated,+ AppDeleted,+ AppStatusChanged,+ CategoryCreated,+ CategoryUpdated,+ CategoryDeleted,+ ChannelCreated,+ ChannelUpdated,+ ChannelDeleted,+ ChannelStatusChanged,+ GiftCardCreated,+ GiftCardUpdated,+ GiftCardDeleted,+ GiftCardStatusChanged,+ MenuCreated,+ MenuUpdated,+ MenuDeleted,+ MenuItemCreated,+ MenuItemUpdated,+ MenuItemDeleted,+ OrderCreated,+ OrderUpdated,+ OrderConfirmed,+ OrderFullyPaid,+ OrderCancelled,+ OrderFulfilled,+ DraftOrderCreated,+ DraftOrderUpdated,+ DraftOrderDeleted,+ ProductCreated,+ ProductUpdated,+ ProductDeleted,+ ProductVariantCreated,+ ProductVariantUpdated,+ ProductVariantOutOfStock,+ ProductVariantBackInStock,+ ProductVariantDeleted,+ SaleCreated,+ SaleUpdated,+ SaleDeleted,+ InvoiceRequested,+ InvoiceDeleted,+ InvoiceSent,+ FulfillmentCreated,+ FulfillmentCanceled,+ CustomerCreated,+ CustomerUpdated,+ CollectionCreated,+ CollectionUpdated,+ CollectionDeleted,+ CheckoutCreated,+ CheckoutUpdated,+ PageCreated,+ PageUpdated,+ PageDeleted,+ ShippingPriceCreated,+ ShippingPriceUpdated,+ ShippingPriceDeleted,+ ShippingZoneCreated,+ ShippingZoneUpdated,+ ShippingZoneDeleted,+ TransactionActionRequest,+ TranslationCreated,+ TranslationUpdated,+ VoucherCreated,+ VoucherUpdated,+ VoucherDeleted,+ WarehouseCreated,+ WarehouseUpdated,+ WarehouseDeleted,+]diff --git a/saleor/plugins/webhook/plugin.py b/saleor/plugins/webhook/plugin.pyindex 32b33ab2eb..3033e8c503 100644--- a/saleor/plugins/webhook/plugin.py+++ b/saleor/plugins/webhook/plugin.py@@ -93,12 +93,16 @@ class WebhookPlugin(BasePlugin):super().__init__(*args, **kwargs)self.active = True+ def _generate_meta(self):+ return generate_meta(requestor_data=generate_requestor(self.requestor))+def _trigger_app_event(self, event_type, app):if webhooks := get_webhooks_for_event(event_type):payload = {"id": graphene.Node.to_global_id("App", app.id),"is_active": app.is_active,"name": app.name,+ "meta": self._generate_meta(),}trigger_webhooks_async(payload, event_type, webhooks, app, self.requestor)@@ -122,84 +126,70 @@ class WebhookPlugin(BasePlugin):return previous_valueself._trigger_app_event(WebhookEventAsyncType.APP_STATUS_CHANGED, app)- def category_created(self, category: "Category", previous_value: None) -> None:- if not self.active:- return previous_value- event_type = WebhookEventAsyncType.CATEGORY_CREATED+ def __trigger_category_event(self, event_type, category):if webhooks := get_webhooks_for_event(event_type):- payload = {"id": graphene.Node.to_global_id("Category", category.id)}+ payload = {+ "id": graphene.Node.to_global_id("Category", category.id),+ "meta": self._generate_meta(),+ }trigger_webhooks_async(payload, event_type, webhooks, category, self.requestor)+ def category_created(self, category: "Category", previous_value: None) -> None:+ if not self.active:+ return previous_value+ self.__trigger_category_event(WebhookEventAsyncType.CATEGORY_CREATED, category)+def category_updated(self, category: "Category", previous_value: None) -> None:if not self.active:return previous_value- event_type = WebhookEventAsyncType.CATEGORY_UPDATED- if webhooks := get_webhooks_for_event(event_type):- payload = {"id": graphene.Node.to_global_id("Category", category.id)}- trigger_webhooks_async(- payload, event_type, webhooks, category, self.requestor- )+ self.__trigger_category_event(WebhookEventAsyncType.CATEGORY_UPDATED, category)def category_deleted(self, category: "Category", previous_value: None) -> None:if not self.active:return previous_value- event_type = WebhookEventAsyncType.CATEGORY_DELETED+ self.__trigger_category_event(WebhookEventAsyncType.CATEGORY_DELETED, category)++ def __trigger_channel_event(self, event_type, channel):if webhooks := get_webhooks_for_event(event_type):- payload = {"id": graphene.Node.to_global_id("Category", category.id)}+ payload = {+ "id": graphene.Node.to_global_id("Channel", channel.id),+ "is_active": channel.is_active,+ "meta": self._generate_meta(),+ }trigger_webhooks_async(- payload, event_type, webhooks, category, self.requestor+ payload, event_type, webhooks, channel, self.requestor)def channel_created(self, channel: "Channel", previous_value: None) -> None:if not self.active:return previous_value- event_type = WebhookEventAsyncType.CHANNEL_CREATED- if webhooks := get_webhooks_for_event(event_type):- payload = {"id": graphene.Node.to_global_id("Channel", channel.id)}- trigger_webhooks_async(- payload, event_type, webhooks, channel, self.requestor- )+ self.__trigger_channel_event(WebhookEventAsyncType.CHANNEL_CREATED, channel)def channel_updated(self, channel: "Channel", previous_value: None) -> None:if not self.active:return previous_value- event_type = WebhookEventAsyncType.CHANNEL_UPDATED- if webhooks := get_webhooks_for_event(event_type):- payload = {"id": graphene.Node.to_global_id("Channel", channel.id)}- trigger_webhooks_async(- payload, event_type, webhooks, channel, self.requestor- )+ self.__trigger_channel_event(WebhookEventAsyncType.CHANNEL_UPDATED, channel)def channel_deleted(self, channel: "Channel", previous_value: None) -> None:if not self.active:return previous_value- event_type = WebhookEventAsyncType.CHANNEL_DELETED- if webhooks := get_webhooks_for_event(event_type):- payload = {"id": graphene.Node.to_global_id("Channel", channel.id)}- trigger_webhooks_async(- payload, event_type, webhooks, channel, self.requestor- )+ self.__trigger_channel_event(WebhookEventAsyncType.CHANNEL_DELETED, channel)def channel_status_changed(self, channel: "Channel", previous_value: None) -> None:if not self.active:return previous_value- event_type = WebhookEventAsyncType.CHANNEL_STATUS_CHANGED- if webhooks := get_webhooks_for_event(event_type):- payload = {- "id": graphene.Node.to_global_id("Channel", channel.id),- "is_active": channel.is_active,- }- trigger_webhooks_async(- payload, event_type, webhooks, channel, self.requestor- )+ self.__trigger_channel_event(+ WebhookEventAsyncType.CHANNEL_STATUS_CHANGED, channel+ )def _trigger_gift_card_event(self, event_type, gift_card):if webhooks := get_webhooks_for_event(event_type):payload = {"id": graphene.Node.to_global_id("GiftCard", gift_card.id),"is_active": gift_card.is_active,+ "meta": self._generate_meta(),}trigger_webhooks_async(payload, event_type, webhooks, gift_card, self.requestor@@ -250,6 +240,7 @@ class WebhookPlugin(BasePlugin):payload = {"id": graphene.Node.to_global_id("Menu", menu.id),"slug": menu.slug,+ "meta": self._generate_meta(),}trigger_webhooks_async(payload, event_type, webhooks, menu, self.requestor)@@ -274,6 +265,7 @@ class WebhookPlugin(BasePlugin):"id": graphene.Node.to_global_id("MenuItem", menu_item.id),"name": menu_item.name,"menu": {"id": graphene.Node.to_global_id("Menu", menu_item.menu_id)},+ "meta": self._generate_meta(),}trigger_webhooks_async(payload, event_type, webhooks, menu_item, self.requestor@@ -719,39 +711,35 @@ class WebhookPlugin(BasePlugin):page_data, event_type, webhooks, page, self.requestor)- def shipping_price_created(- self, shipping_method: "ShippingMethod", previous_value: None- ) -> None:- if not self.active:- return previous_value-- event_type = WebhookEventAsyncType.SHIPPING_PRICE_CREATED+ def _trigger_shipping_price_event(self, event_type, shipping_method):if webhooks := get_webhooks_for_event(event_type):payload = {"id": graphene.Node.to_global_id("ShippingMethodType", shipping_method.id- )+ ),+ "meta": self._generate_meta(),}trigger_webhooks_async(payload, event_type, webhooks, shipping_method, self.requestor)- def shipping_price_updated(+ def shipping_price_created(self, shipping_method: "ShippingMethod", previous_value: None) -> None:if not self.active:return previous_value+ self._trigger_shipping_price_event(+ WebhookEventAsyncType.SHIPPING_PRICE_CREATED, shipping_method+ )- event_type = WebhookEventAsyncType.SHIPPING_PRICE_UPDATED- if webhooks := get_webhooks_for_event(event_type):- payload = {- "id": graphene.Node.to_global_id(- "ShippingMethodType", shipping_method.id- )- }- trigger_webhooks_async(- payload, event_type, webhooks, shipping_method, self.requestor- )+ def shipping_price_updated(+ self, shipping_method: "ShippingMethod", previous_value: None+ ) -> None:+ if not self.active:+ return previous_value+ self._trigger_shipping_price_event(+ WebhookEventAsyncType.SHIPPING_PRICE_UPDATED, shipping_method+ )def shipping_price_deleted(self, shipping_method: "ShippingMethod", previous_value: None@@ -759,15 +747,18 @@ class WebhookPlugin(BasePlugin):if not self.active:return previous_value- event_type = WebhookEventAsyncType.SHIPPING_PRICE_DELETED+ self._trigger_shipping_price_event(+ WebhookEventAsyncType.SHIPPING_PRICE_DELETED, shipping_method+ )++ def _trigger_shipping_zone_event(self, event_type, shipping_zone):if webhooks := get_webhooks_for_event(event_type):payload = {- "id": graphene.Node.to_global_id(- "ShippingMethodType", shipping_method.id- )+ "id": graphene.Node.to_global_id("ShippingZone", shipping_zone.id),+ "meta": self._generate_meta(),}trigger_webhooks_async(- payload, event_type, webhooks, shipping_method, self.requestor+ payload, event_type, webhooks, shipping_zone, self.requestor)def shipping_zone_created(@@ -775,45 +766,27 @@ class WebhookPlugin(BasePlugin):) -> None:if not self.active:return previous_value-- event_type = WebhookEventAsyncType.SHIPPING_ZONE_CREATED- if webhooks := get_webhooks_for_event(event_type):- payload = {- "id": graphene.Node.to_global_id("ShippingZone", shipping_zone.id)- }- trigger_webhooks_async(- payload, event_type, webhooks, shipping_zone, self.requestor- )+ self._trigger_shipping_zone_event(+ WebhookEventAsyncType.SHIPPING_ZONE_CREATED, shipping_zone+ )def shipping_zone_updated(self, shipping_zone: "ShippingZone", previous_value: None) -> None:if not self.active:return previous_value-- event_type = WebhookEventAsyncType.SHIPPING_ZONE_UPDATED- if webhooks := get_webhooks_for_event(event_type):- payload = {- "id": graphene.Node.to_global_id("ShippingZone", shipping_zone.id)- }- trigger_webhooks_async(- payload, event_type, webhooks, shipping_zone, self.requestor- )+ self._trigger_shipping_zone_event(+ WebhookEventAsyncType.SHIPPING_ZONE_UPDATED, shipping_zone+ )def shipping_zone_deleted(self, shipping_zone: "ShippingZone", previous_value: None) -> None:if not self.active:return previous_value-- event_type = WebhookEventAsyncType.SHIPPING_ZONE_DELETED- if webhooks := get_webhooks_for_event(event_type):- payload = {- "id": graphene.Node.to_global_id("ShippingZone", shipping_zone.id)- }- trigger_webhooks_async(- payload, event_type, webhooks, shipping_zone, self.requestor- )+ self._trigger_shipping_zone_event(+ WebhookEventAsyncType.SHIPPING_ZONE_DELETED, shipping_zone+ )def translation_created(self, translation: "Translation", previous_value: Any):if not self.active:@@ -872,6 +845,7 @@ class WebhookPlugin(BasePlugin):"id": graphene.Node.to_global_id("Voucher", voucher.id),"name": voucher.name,"code": voucher.code,+ "meta": self._generate_meta(),}trigger_webhooks_async(payload, event_type, webhooks, voucher, self.requestordiff --git a/saleor/plugins/webhook/tasks.py b/saleor/plugins/webhook/tasks.pyindex 179acab468..dba7fd3a4f 100644--- a/saleor/plugins/webhook/tasks.py+++ b/saleor/plugins/webhook/tasks.py@@ -26,7 +26,6 @@ from ...payment import PaymentErrorfrom ...settings import WEBHOOK_SYNC_TIMEOUT, WEBHOOK_TIMEOUTfrom ...site.models import Sitefrom ...webhook.event_types import SUBSCRIBABLE_EVENTS-from ...webhook.payloads import generate_meta, generate_requestorfrom ...webhook.utils import get_webhooks_for_eventfrom . import signature_for_payloadfrom .utils import (@@ -63,7 +62,7 @@ class WebhookResponse:def create_deliveries_for_subscriptions(- event_type, subscribable_object, webhooks, meta=None+ event_type, subscribable_object, webhooks, requestor=None) -> List[EventDelivery]:"""Create webhook payload based on subscription query.@@ -72,6 +71,7 @@ def create_deliveries_for_subscriptions(:param event_type: event type which should be triggered.:param subscribable_object: subscribable object to process via subscription query.+ :param requestor: used in subscription webhooks to generate meta data for payload.:return: List of event deliveries to send via webhook tasks."""if event_type not in SUBSCRIBABLE_EVENTS:@@ -80,7 +80,8 @@ def create_deliveries_for_subscriptions()return []- context = initialize_context()+ context = initialize_context(requestor)+event_payloads = []event_deliveries = []for webhook in webhooks:@@ -97,7 +98,7 @@ def create_deliveries_for_subscriptions()continue- event_payload = EventPayload(payload=json.dumps({**data, "meta": meta}))+ event_payload = EventPayload(payload=json.dumps({**data}))event_payloads.append(event_payload)event_deliveries.append(EventDelivery(@@ -136,17 +137,12 @@ def trigger_webhooks_async())if subscription_webhooks:- meta = {}- if requestor:- meta = generate_meta(- requestor_data=generate_requestor(requestor), camel_case=True- )deliveries.extend(create_deliveries_for_subscriptions(event_type=event_type,subscribable_object=subscribable_object,webhooks=subscription_webhooks,- meta=meta,+ requestor=requestor,))diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py b/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.pyindex 2db0d5b9cb..e5142b3ffa 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py@@ -20,122 +20,35 @@ def subscription_webhook(webhook_app):return fun-APP_DETAILS_FRAGMENT = """- fragment AppDetails on App{- id- isActive- name- appUrl- }-"""---APP_INSTALLED_SUBSCRIPTION_QUERY = (- APP_DETAILS_FRAGMENT- + """- subscription{- event{- ...on AppInstalled{- app{- ...AppDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_app_installed_webhook(subscription_webhook):return subscription_webhook(- APP_INSTALLED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.APP_INSTALLED+ subscription_queries.APP_INSTALLED, WebhookEventAsyncType.APP_INSTALLED)-APP_UPDATED_SUBSCRIPTION_QUERY = (- APP_DETAILS_FRAGMENT- + """- subscription{- event{- ...on AppUpdated{- app{- ...AppDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_app_updated_webhook(subscription_webhook):return subscription_webhook(- APP_UPDATED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.APP_UPDATED+ subscription_queries.APP_UPDATED, WebhookEventAsyncType.APP_UPDATED)-APP_DELETED_SUBSCRIPTION_QUERY = (- APP_DETAILS_FRAGMENT- + """- subscription{- event{- ...on AppDeleted{- app{- ...AppDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_app_deleted_webhook(subscription_webhook):return subscription_webhook(- APP_DELETED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.APP_DELETED+ subscription_queries.APP_DELETED, WebhookEventAsyncType.APP_DELETED)-APP_STATUS_CHANGED_SUBSCRIPTION_QUERY = (- APP_DETAILS_FRAGMENT- + """- subscription{- event{- ...on AppStatusChanged{- app{- ...AppDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_app_status_changed_webhook(subscription_webhook):return subscription_webhook(- APP_STATUS_CHANGED_SUBSCRIPTION_QUERY,+ subscription_queries.APP_STATUS_CHANGED,WebhookEventAsyncType.APP_STATUS_CHANGED,)-CATEGORY_CREATED_SUBSCRIPTION_QUERY = """- subscription{- event{- ...on CategoryCreated{- category{- id- }- }- }- }-"""--@pytest.fixturedef subscription_category_created_webhook(subscription_webhook):return subscription_webhook(@@ -215,192 +128,48 @@ def subscription_gift_card_status_changed_webhook(subscription_webhook):)-MENU_DETAILS_FRAGMENT = """- fragment MenuDetails on Menu{- id- name- slug- items {- id- name- }- }-"""--MENU_CREATED_SUBSCRIPTION_QUERY = (- MENU_DETAILS_FRAGMENT- + """- subscription{- event{- ...on MenuCreated{- menu{- ...MenuDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_menu_created_webhook(subscription_webhook):return subscription_webhook(- MENU_CREATED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.MENU_CREATED+ subscription_queries.MENU_CREATED, WebhookEventAsyncType.MENU_CREATED)-MENU_UPDATED_SUBSCRIPTION_QUERY = (- MENU_DETAILS_FRAGMENT- + """- subscription{- event{- ...on MenuUpdated{- menu{- ...MenuDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_menu_updated_webhook(subscription_webhook):return subscription_webhook(- MENU_UPDATED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.MENU_UPDATED+ subscription_queries.MENU_UPDATED, WebhookEventAsyncType.MENU_UPDATED)-MENU_DELETED_SUBSCRIPTION_QUERY = (- MENU_DETAILS_FRAGMENT- + """- subscription{- event{- ...on MenuDeleted{- menu{- ...MenuDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_menu_deleted_webhook(subscription_webhook):return subscription_webhook(- MENU_DELETED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.MENU_DELETED+ subscription_queries.MENU_DELETED, WebhookEventAsyncType.MENU_DELETED)-MENU_ITEM_DETAILS_FRAGMENT = """- fragment MenuItemDetails on MenuItem{- id- name- menu {- id- }- page {- id- }- }-"""--MENU_ITEM_CREATED_SUBSCRIPTION_QUERY = (- MENU_ITEM_DETAILS_FRAGMENT- + """- subscription{- event{- ...on MenuItemCreated{- menuItem{- ...MenuItemDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_menu_item_created_webhook(subscription_webhook):return subscription_webhook(- MENU_ITEM_CREATED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.MENU_ITEM_CREATED+ subscription_queries.MENU_ITEM_CREATED, WebhookEventAsyncType.MENU_ITEM_CREATED)-MENU_ITEM_UPDATED_SUBSCRIPTION_QUERY = (- MENU_ITEM_DETAILS_FRAGMENT- + """- subscription{- event{- ...on MenuItemUpdated{- menuItem{- ...MenuItemDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_menu_item_updated_webhook(subscription_webhook):return subscription_webhook(- MENU_ITEM_UPDATED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.MENU_ITEM_UPDATED+ subscription_queries.MENU_ITEM_UPDATED, WebhookEventAsyncType.MENU_ITEM_UPDATED)-MENU_ITEM_DELETED_SUBSCRIPTION_QUERY = (- MENU_ITEM_DETAILS_FRAGMENT- + """- subscription{- event{- ...on MenuItemDeleted{- menuItem{- ...MenuItemDetails- }- }- }- }-"""-)--@pytest.fixturedef subscription_menu_item_deleted_webhook(subscription_webhook):return subscription_webhook(- MENU_ITEM_DELETED_SUBSCRIPTION_QUERY, WebhookEventAsyncType.MENU_ITEM_DELETED+ subscription_queries.MENU_ITEM_DELETED, WebhookEventAsyncType.MENU_ITEM_DELETED)-SHIPPING_PRICE_CREATED_SUBSCRIPTION_QUERY = """- subscription{- event{- ...on ShippingPriceCreated{- shippingMethod{- id- name- channelListings {- channel {- name- }- }- }- shippingZone{- id- name- }- }- }- }-"""--@pytest.fixturedef subscription_shipping_price_created_webhook(subscription_webhook):return subscription_webhook(@@ -773,3 +542,11 @@ def subscription_voucher_deleted_webhook(subscription_webhook):return subscription_webhook(subscription_queries.VOUCHER_DELETED, WebhookEventAsyncType.VOUCHER_DELETED)+++def subscription_voucher_webhook_with_meta(subscription_webhook):+ return subscription_webhook(+ subscription_queries.VOUCHER_CREATED_WITH_META,+ WebhookEventAsyncType.VOUCHER_CREATED,+ )diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/payloads.py b/saleor/plugins/webhook/tests/subscription_webhooks/payloads.pyindex 2b4a5c0f48..0ae461c8de 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/payloads.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/payloads.py@@ -1,8 +1,23 @@import jsonimport graphene+from django.utils import timezone-from saleor.product.models import Product+from ..... import __version__+from .....product.models import Product+++def generate_app_payload(app, app_global_id):+ return json.dumps(+ {+ "app": {+ "id": app_global_id,+ "isActive": app.is_active,+ "name": app.name,+ "appUrl": app.app_url,+ }+ }+ )def generate_taxed_money_payload(taxed_money):@@ -49,8 +64,7 @@ def generate_fulfillment_payload(fulfillment):"trackingNumber": fulfillment.tracking_number,"status": fulfillment.status.upper(),"lines": generate_fulfillment_lines_payload(fulfillment),- },- "meta": None,+ }}@@ -90,8 +104,7 @@ def generate_customer_payload(customer):"defaultBillingAddress": (generate_address_payload(customer.default_billing_address)),- },- "meta": None,+ }}@@ -114,8 +127,7 @@ def generate_collection_payload(collection):"slug": collection.slug,"channel": "main","products": {"edges": products_node},- },- "meta": None,+ }}@@ -149,8 +161,7 @@ def generate_page_payload(page):},{"attribute": {"slug": page_attributes[1].slug}, "values": []},],- },- "meta": None,+ }}@@ -160,8 +171,7 @@ def generate_invoice_payload(invoice):"id": graphene.Node.to_global_id("Invoice", invoice.pk),"status": invoice.status.upper(),"number": invoice.number,- },- "meta": None,+ }}@@ -188,8 +198,7 @@ def generate_category_payload(category):for product in products]},- },- "meta": None,+ }}@@ -215,7 +224,6 @@ def generate_shipping_method_payload(shipping_method):"id": shipping_zone_id,"name": shipping_method.shipping_zone.name,},- "meta": None,}@@ -237,8 +245,7 @@ def generate_sale_payload(sale):for category in sale.categories.all()]},- },- "meta": None,+ }}@@ -250,12 +257,48 @@ def generate_voucher_payload(voucher, voucher_global_id):"name": voucher.name,"code": voucher.code,"usageLimit": voucher.usage_limit,- },- "meta": None,+ }})+def generate_voucher_created_payload_with_meta(+ voucher, voucher_global_id, requestor, requestor_type, webhook_app+):+ data = {+ "__typename": "VoucherCreated",+ "issuedAt": timezone.now().isoformat(),+ "version": __version__,+ "issuingPrincipal": None,+ "recipient": {+ "id": graphene.Node.to_global_id("App", webhook_app.id),+ "name": webhook_app.name,+ },+ "voucher": {+ "id": voucher_global_id,+ "name": voucher.name,+ "code": voucher.code,+ "usageLimit": voucher.usage_limit,+ },+ }++ if requestor_type == "user":+ data["issuingPrincipal"] = {+ "__typename": "User",+ "id": graphene.Node.to_global_id("User", requestor.id),+ "email": requestor.email,+ }++ if requestor_type == "app":+ data["issuingPrincipal"] = {+ "__typename": "App",+ "id": graphene.Node.to_global_id("App", requestor.id),+ "name": requestor.name,+ }++ return json.dumps(data)++def generate_gift_card_payload(gift_card, card_global_id):return json.dumps({@@ -264,8 +307,7 @@ def generate_gift_card_payload(gift_card, card_global_id):"isActive": gift_card.is_active,"code": gift_card.code,"createdBy": {"email": gift_card.created_by.email},- },- "meta": None,+ }})@@ -284,8 +326,7 @@ def generate_menu_payload(menu, menu_global_id):}for item in menu_items],- },- "meta": None,+ }}@@ -306,8 +347,7 @@ def generate_menu_item_payload(menu_item, menu_item_global_id):"name": menu_item.name,"menu": menu,"page": page,- },- "meta": None,+ }}@@ -330,7 +370,6 @@ def generate_warehouse_payload(warehouse, warehouse_global_id):]},"address": {"companyName": warehouse.address.company_name},- },- "meta": None,+ }})diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py b/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.pyindex 10bcdcccc9..835057fac1 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py@@ -1,5 +1,68 @@from .....graphql.tests.queries import fragments+APP_INSTALLED = (+ fragments.APP_DETAILS+ + """+ subscription{+ event{+ ...on AppInstalled{+ app{+ ...AppDetails+ }+ }+ }+ }+"""+)++APP_UPDATED = (+ fragments.APP_DETAILS+ + """+ subscription{+ event{+ ...on AppUpdated{+ app{+ ...AppDetails+ }+ }+ }+ }+"""+)+++APP_DELETED = (+ fragments.APP_DETAILS+ + """+ subscription{+ event{+ ...on AppDeleted{+ app{+ ...AppDetails+ }+ }+ }+ }+"""+)+++APP_STATUS_CHANGED = (+ fragments.APP_DETAILS+ + """+ subscription{+ event{+ ...on AppStatusChanged{+ app{+ ...AppDetails+ }+ }+ }+ }+"""+)++GIFT_CARD_CREATED = (fragments.GIFT_CARD_DETAILS+ """@@ -79,6 +142,39 @@ VOUCHER_CREATED = ()+VOUCHER_CREATED_WITH_META = (+ fragments.VOUCHER_DETAILS+ + """+ subscription{+ event{+ __typename+ issuedAt+ version+ issuingPrincipal{+ __typename+ ...on App{+ id+ name+ }+ ...on User{+ id+ }+ }+ recipient{+ id+ name+ }+ ...on VoucherCreated{+ voucher{+ ...VoucherDetails+ }+ }+ }+ }+"""+)+VOUCHER_UPDATED = (fragments.VOUCHER_DETAILS+ """@@ -990,6 +1086,102 @@ TEST_VALID_SUBSCRIPTION_QUERY = """"""+MENU_CREATED = (+ fragments.MENU_DETAILS+ + """+ subscription{+ event{+ ...on MenuCreated{+ menu{+ ...MenuDetails+ }+ }+ }+ }+"""+)+++MENU_UPDATED = (+ fragments.MENU_DETAILS+ + """+ subscription{+ event{+ ...on MenuUpdated{+ menu{+ ...MenuDetails+ }+ }+ }+ }+"""+)+++MENU_DELETED = (+ fragments.MENU_DETAILS+ + """+ subscription{+ event{+ ...on MenuDeleted{+ menu{+ ...MenuDetails+ }+ }+ }+ }+"""+)+++MENU_ITEM_CREATED = (+ fragments.MENU_ITEM_DETAILS+ + """+ subscription{+ event{+ ...on MenuItemCreated{+ menuItem{+ ...MenuItemDetails+ }+ }+ }+ }+"""+)+++MENU_ITEM_UPDATED = (+ fragments.MENU_ITEM_DETAILS+ + """+ subscription{+ event{+ ...on MenuItemUpdated{+ menuItem{+ ...MenuItemDetails+ }+ }+ }+ }+"""+)+++MENU_ITEM_DELETED = (+ fragments.MENU_ITEM_DETAILS+ + """+ subscription{+ event{+ ...on MenuItemDeleted{+ menuItem{+ ...MenuItemDetails+ }+ }+ }+ }+"""+)++WAREHOUSE_CREATED = (fragments.WAREHOUSE_DETAILS+ """diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.pyindex 2d32c891d0..42147257ce 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_subscription.py@@ -3,6 +3,8 @@ from unittest.mock import patchimport grapheneimport pytest+from django.contrib.auth.models import AnonymousUser+from freezegun import freeze_timefrom .....channel.models import Channelfrom .....giftcard.models import GiftCard@@ -14,6 +16,7 @@ from .....webhook.event_types import WebhookEventAsyncTypefrom ...tasks import create_deliveries_for_subscriptions, loggerfrom . import subscription_queriesfrom .payloads import (+ generate_app_payload,generate_category_payload,generate_collection_payload,generate_customer_payload,@@ -25,24 +28,47 @@ from .payloads import (generate_page_payload,generate_sale_payload,generate_shipping_method_payload,+ generate_voucher_created_payload_with_meta,generate_voucher_payload,generate_warehouse_payload,)-def generate_expected_payload_for_app(app, app_global_id):- return json.dumps(- {- "app": {- "id": app_global_id,- "isActive": app.is_active,- "name": app.name,- "appUrl": app.app_url,- },- "meta": None,- }+@freeze_time("2022-05-12 12:00:00")[email protected]("requestor_type", ["user", "app", None, "anonymous"])+def test_subscription_query_with_meta(+ requestor_type, voucher, staff_user, app, subscription_voucher_webhook_with_meta+):+ # given+ requestor_map = {+ "user": staff_user,+ "app": app,+ None: None,+ "anonymous": AnonymousUser(),+ }+ webhooks = [subscription_voucher_webhook_with_meta]+ event_type = WebhookEventAsyncType.VOUCHER_CREATED+ voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)++ requestor = requestor_map[requestor_type]++ # when+ deliveries = create_deliveries_for_subscriptions(+ event_type, voucher, webhooks, requestor)+ # then+ expected_payload = generate_voucher_created_payload_with_meta(+ voucher,+ voucher_id,+ requestor,+ requestor_type,+ subscription_voucher_webhook_with_meta.app,+ )+ assert deliveries[0].payload.payload == expected_payload+ assert len(deliveries) == len(webhooks)+ assert deliveries[0].webhook == webhooks[0]+def test_app_installed(app, subscription_app_installed_webhook):# given@@ -54,7 +80,7 @@ def test_app_installed(app, subscription_app_installed_webhook):deliveries = create_deliveries_for_subscriptions(event_type, app, webhooks)# then- expected_payload = generate_expected_payload_for_app(app, app_id)+ expected_payload = generate_app_payload(app, app_id)assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -70,7 +96,7 @@ def test_app_updated(app, subscription_app_updated_webhook):deliveries = create_deliveries_for_subscriptions(event_type, app, webhooks)# then- expected_payload = generate_expected_payload_for_app(app, gift_card_id)+ expected_payload = generate_app_payload(app, gift_card_id)assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -91,7 +117,7 @@ def test_app_deleted(app, subscription_app_deleted_webhook):deliveries = create_deliveries_for_subscriptions(event_type, app, webhooks)# then- expected_payload = generate_expected_payload_for_app(app, app_id)+ expected_payload = generate_app_payload(app, app_id)assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -112,7 +138,7 @@ def test_app_status_changed(status, app, subscription_app_status_changed_webhookdeliveries = create_deliveries_for_subscriptions(event_type, app, webhooks)# then- expected_payload = generate_expected_payload_for_app(app, app_id)+ expected_payload = generate_app_payload(app, app_id)assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -178,7 +204,7 @@ def test_category_deleted(category, subscription_category_deleted_webhook):)# then- expected_payload = json.dumps({"category": {"id": category_id}, "meta": None})+ expected_payload = json.dumps({"category": {"id": category_id}})assert category_instances[0].id is not Noneassert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -195,7 +221,7 @@ def test_channel_created(channel_USD, subscription_channel_created_webhook):deliveries = create_deliveries_for_subscriptions(event_type, channel_USD, webhooks)# then- expected_payload = json.dumps({"channel": {"id": channel_id}, "meta": None})+ expected_payload = json.dumps({"channel": {"id": channel_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -211,7 +237,7 @@ def test_channel_updated(channel_USD, subscription_channel_updated_webhook):deliveries = create_deliveries_for_subscriptions(event_type, channel_USD, webhooks)# then- expected_payload = json.dumps({"channel": {"id": channel_id}, "meta": None})+ expected_payload = json.dumps({"channel": {"id": channel_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -234,7 +260,7 @@ def test_channel_deleted(channel_USD, subscription_channel_deleted_webhook):)# then- expected_payload = json.dumps({"channel": {"id": channel_id}, "meta": None})+ expected_payload = json.dumps({"channel": {"id": channel_id}})assert channel_instances[0].id is not Noneassert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -258,9 +284,7 @@ def test_channel_status_changed(deliveries = create_deliveries_for_subscriptions(event_type, channel_USD, webhooks)# then- expected_payload = json.dumps(- {"channel": {"id": channel_id, "isActive": status}, "meta": None}- )+ expected_payload = json.dumps({"channel": {"id": channel_id, "isActive": status}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -519,10 +543,7 @@ def test_shipping_price_deleted(# thenexpected_payload = json.dumps(- {- "shippingMethod": {"id": shipping_method_id, "name": shipping_method.name},- "meta": None,- }+ {"shippingMethod": {"id": shipping_method_id, "name": shipping_method.name}})assert method_instances[0].id is not Noneassert deliveries[0].payload.payload == expected_payload@@ -551,8 +572,7 @@ def test_shipping_zone_created("name": shipping_zone.name,"countries": [{"code": c.code} for c in shipping_zone.countries],"channels": [{"name": c.name} for c in shipping_zone.channels.all()],- },- "meta": None,+ }})@@ -582,8 +602,7 @@ def test_shipping_zone_updated("name": shipping_zone.name,"countries": [{"code": c.code} for c in shipping_zone.countries],"channels": [{"name": c.name} for c in shipping_zone.channels.all()],- },- "meta": None,+ }})assert deliveries[0].payload.payload == expected_payload@@ -613,7 +632,6 @@ def test_shipping_zone_deleted(expected_payload = json.dumps({"shippingZone": {"id": shipping_zone_id, "name": shipping_zone.name},- "meta": None,})assert zones_instances[0].id is not None@@ -627,7 +645,7 @@ def test_product_created(product, subscription_product_created_webhook):event_type = WebhookEventAsyncType.PRODUCT_CREATEDproduct_id = graphene.Node.to_global_id("Product", product.id)deliveries = create_deliveries_for_subscriptions(event_type, product, webhooks)- expected_payload = json.dumps({"product": {"id": product_id}, "meta": None})+ expected_payload = json.dumps({"product": {"id": product_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -639,7 +657,7 @@ def test_product_updated(product, subscription_product_updated_webhook):event_type = WebhookEventAsyncType.PRODUCT_UPDATEDproduct_id = graphene.Node.to_global_id("Product", product.id)deliveries = create_deliveries_for_subscriptions(event_type, product, webhooks)- expected_payload = json.dumps({"product": {"id": product_id}, "meta": None})+ expected_payload = json.dumps({"product": {"id": product_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -651,7 +669,7 @@ def test_product_deleted(product, subscription_product_deleted_webhook):event_type = WebhookEventAsyncType.PRODUCT_DELETEDproduct_id = graphene.Node.to_global_id("Product", product.id)deliveries = create_deliveries_for_subscriptions(event_type, product, webhooks)- expected_payload = json.dumps({"product": {"id": product_id}, "meta": None})+ expected_payload = json.dumps({"product": {"id": product_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -663,7 +681,7 @@ def test_product_variant_created(variant, subscription_product_variant_created_wevent_type = WebhookEventAsyncType.PRODUCT_VARIANT_CREATEDvariant_id = graphene.Node.to_global_id("ProductVariant", variant.id)deliveries = create_deliveries_for_subscriptions(event_type, variant, webhooks)- expected_payload = json.dumps({"productVariant": {"id": variant_id}, "meta": None})+ expected_payload = json.dumps({"productVariant": {"id": variant_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -675,7 +693,7 @@ def test_product_variant_updated(variant, subscription_product_variant_updated_wevent_type = WebhookEventAsyncType.PRODUCT_VARIANT_UPDATEDvariant_id = graphene.Node.to_global_id("ProductVariant", variant.id)deliveries = create_deliveries_for_subscriptions(event_type, variant, webhooks)- expected_payload = json.dumps({"productVariant": {"id": variant_id}, "meta": None})+ expected_payload = json.dumps({"productVariant": {"id": variant_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -687,7 +705,7 @@ def test_product_variant_deleted(variant, subscription_product_variant_deleted_wevent_type = WebhookEventAsyncType.PRODUCT_VARIANT_DELETEDvariant_id = graphene.Node.to_global_id("ProductVariant", variant.id)deliveries = create_deliveries_for_subscriptions(event_type, variant, webhooks)- expected_payload = json.dumps({"productVariant": {"id": variant_id}, "meta": None})+ expected_payload = json.dumps({"productVariant": {"id": variant_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -701,7 +719,7 @@ def test_product_variant_out_of_stock(event_type = WebhookEventAsyncType.PRODUCT_VARIANT_OUT_OF_STOCKvariant_id = graphene.Node.to_global_id("ProductVariant", stock.product_variant.id)deliveries = create_deliveries_for_subscriptions(event_type, stock, webhooks)- expected_payload = json.dumps({"productVariant": {"id": variant_id}, "meta": None})+ expected_payload = json.dumps({"productVariant": {"id": variant_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -715,7 +733,7 @@ def test_product_variant_back_in_stock(event_type = WebhookEventAsyncType.PRODUCT_VARIANT_BACK_IN_STOCKvariant_id = graphene.Node.to_global_id("ProductVariant", stock.product_variant.id)deliveries = create_deliveries_for_subscriptions(event_type, stock, webhooks)- expected_payload = json.dumps({"productVariant": {"id": variant_id}, "meta": None})+ expected_payload = json.dumps({"productVariant": {"id": variant_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -727,7 +745,7 @@ def test_order_created(order, subscription_order_created_webhook):event_type = WebhookEventAsyncType.ORDER_CREATEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -739,7 +757,7 @@ def test_order_confirmed(order, subscription_order_confirmed_webhook):event_type = WebhookEventAsyncType.ORDER_CONFIRMEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -751,7 +769,7 @@ def test_order_fully_paid(order, subscription_order_fully_paid_webhook):event_type = WebhookEventAsyncType.ORDER_FULLY_PAIDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -763,7 +781,7 @@ def test_order_updated(order, subscription_order_updated_webhook):event_type = WebhookEventAsyncType.ORDER_UPDATEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -775,7 +793,7 @@ def test_order_cancelled(order, subscription_order_cancelled_webhook):event_type = WebhookEventAsyncType.ORDER_CANCELLEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -787,7 +805,7 @@ def test_order_fulfilled(order, subscription_order_fulfilled_webhook):event_type = WebhookEventAsyncType.ORDER_FULFILLEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -799,7 +817,7 @@ def test_draft_order_created(order, subscription_draft_order_created_webhook):event_type = WebhookEventAsyncType.DRAFT_ORDER_CREATEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -811,7 +829,7 @@ def test_draft_order_updated(order, subscription_draft_order_updated_webhook):event_type = WebhookEventAsyncType.DRAFT_ORDER_UPDATEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -823,7 +841,7 @@ def test_draft_order_deleted(order, subscription_draft_order_deleted_webhook):event_type = WebhookEventAsyncType.DRAFT_ORDER_DELETEDorder_id = graphene.Node.to_global_id("Order", order.id)deliveries = create_deliveries_for_subscriptions(event_type, order, webhooks)- expected_payload = json.dumps({"order": {"id": order_id}, "meta": None})+ expected_payload = json.dumps({"order": {"id": order_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -1046,7 +1064,7 @@ def test_checkout_create(checkout, subscription_checkout_created_webhook):event_type = WebhookEventAsyncType.CHECKOUT_CREATEDcheckout_id = graphene.Node.to_global_id("Checkout", checkout.pk)deliveries = create_deliveries_for_subscriptions(event_type, checkout, webhooks)- expected_payload = json.dumps({"checkout": {"id": checkout_id}, "meta": None})+ expected_payload = json.dumps({"checkout": {"id": checkout_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)assert deliveries[0].webhook == webhooks[0]@@ -1057,7 +1075,7 @@ def test_checkout_update(checkout, subscription_checkout_updated_webhook):event_type = WebhookEventAsyncType.CHECKOUT_UPDATEDcheckout_id = graphene.Node.to_global_id("Checkout", checkout.pk)deliveries = create_deliveries_for_subscriptions(event_type, checkout, webhooks)- expected_payload = json.dumps({"checkout": {"id": checkout_id}, "meta": None})+ expected_payload = json.dumps({"checkout": {"id": checkout_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -1116,7 +1134,7 @@ def test_product_created_multiple_events_in_subscription(event_type = WebhookEventAsyncType.PRODUCT_CREATEDproduct_id = graphene.Node.to_global_id("Product", product.id)deliveries = create_deliveries_for_subscriptions(event_type, product, webhooks)- expected_payload = json.dumps({"product": {"id": product_id}, "meta": None})+ expected_payload = json.dumps({"product": {"id": product_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_action_request_subscription.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_action_request_subscription.pyindex eb639da4ba..d69ca4f761 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_action_request_subscription.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_transaction_action_request_subscription.py@@ -112,7 +112,6 @@ def test_transaction_refund_action_request("actionType": "REFUND","amount": quantize_price(action_value, "USD"),},- "meta": None,}@@ -175,7 +174,6 @@ def test_transaction_charge_action_request("actionType": "CHARGE","amount": quantize_price(action_value, "USD"),},- "meta": None,}@@ -234,5 +232,4 @@ def test_transaction_void_action_request("reference": "PSP ref",},"action": {"actionType": "VOID", "amount": None},- "meta": None,}diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.pyindex f938d68e06..59610e61ed 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py@@ -18,7 +18,7 @@ def test_translation_created_product(event_type, product_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -37,7 +37,7 @@ def test_translation_created_product_variant(event_type, variant_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -56,7 +56,7 @@ def test_translation_created_collection(event_type, collection_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -75,7 +75,7 @@ def test_translation_created_category(event_type, category_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -94,7 +94,7 @@ def test_translation_created_attribute(event_type, translated_attribute, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -113,7 +113,7 @@ def test_translation_created_attribute_value(event_type, translated_attribute_value, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -132,7 +132,7 @@ def test_translation_created_page(event_type, page_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -151,7 +151,7 @@ def test_translation_created_shipping_method(event_type, shipping_method_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -170,7 +170,7 @@ def test_translation_created_sale(event_type, sale_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -189,7 +189,7 @@ def test_translation_created_voucher(event_type, voucher_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -208,7 +208,7 @@ def test_translation_created_menu_item(event_type, menu_item_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -227,7 +227,7 @@ def test_translation_updated_product(event_type, product_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -246,7 +246,7 @@ def test_translation_updated_product_variant(event_type, variant_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -265,7 +265,7 @@ def test_translation_updated_collection(event_type, collection_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -284,7 +284,7 @@ def test_translation_updated_category(event_type, category_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -303,7 +303,7 @@ def test_translation_updated_attribute(event_type, translated_attribute, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -322,7 +322,7 @@ def test_translation_updated_attribute_value(event_type, translated_attribute_value, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -341,7 +341,7 @@ def test_translation_updated_page(event_type, page_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -360,7 +360,7 @@ def test_translation_updated_shipping_method(event_type, shipping_method_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -379,7 +379,7 @@ def test_translation_updated_sale(event_type, sale_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -398,7 +398,7 @@ def test_translation_updated_voucher(event_type, voucher_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)@@ -417,7 +417,7 @@ def test_translation_updated_menu_item(event_type, menu_item_translation_fr, webhooks)- expected_payload = json.dumps({"translation": {"id": translation_id}, "meta": None})+ expected_payload = json.dumps({"translation": {"id": translation_id}})assert deliveries[0].payload.payload == expected_payloadassert len(deliveries) == len(webhooks)diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.pyindex 1fc0a6499f..e97f6481b4 100644--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_webhook.py@@ -1,11 +1,8 @@import dataclassesfrom unittest import mock-from freezegun import freeze_time-from .....webhook.event_types import WebhookEventAsyncTypefrom .....webhook.models import Webhook-from .....webhook.payloads import generate_meta, generate_requestorfrom ...tasks import trigger_webhooks_asyncTEST_ID = "test_id"@@ -16,55 +13,6 @@ class FakeDelivery:id = TEST_ID[email protected]("saleor.plugins.webhook.tasks.send_webhook_request_async.delay")[email protected]("saleor.plugins.webhook.tasks.create_deliveries_for_subscriptions")-def test_trigger_webhooks_async_without_meta(- mocked_create_deliveries_for_subscription,- mocked_send_webhook_request,- subscription_order_updated_webhook,- order,-):- webhook = subscription_order_updated_webhook- webhook_type = WebhookEventAsyncType.ORDER_UPDATED- mocked_create_deliveries_for_subscription.return_value = [FakeDelivery()]-- data = {"regular_webhook": "data"}- trigger_webhooks_async(data, webhook_type, [webhook], order)- mocked_create_deliveries_for_subscription.assert_called_once_with(- event_type=webhook_type,- subscribable_object=order,- webhooks=[webhook],- meta={},- )- mocked_send_webhook_request.assert_called_once_with(TEST_ID)---@freeze_time("2018-05-31 12:00:01")[email protected]("saleor.plugins.webhook.tasks.send_webhook_request_async.delay")[email protected]("saleor.plugins.webhook.tasks.create_deliveries_for_subscriptions")-def test_trigger_webhooks_async_with_meta(- mocked_create_deliveries_for_subscription,- mocked_send_webhook_request,- subscription_order_updated_webhook,- order,- staff_user,-):- webhook = subscription_order_updated_webhook- webhook_type = WebhookEventAsyncType.ORDER_UPDATED- mocked_create_deliveries_for_subscription.return_value = [FakeDelivery()]- data = {"regular_webhook": "data"}- trigger_webhooks_async(data, webhook_type, [webhook], order, staff_user)- mocked_create_deliveries_for_subscription.assert_called_once_with(- event_type=webhook_type,- subscribable_object=order,- webhooks=[webhook],- meta=generate_meta(- requestor_data=generate_requestor(staff_user), camel_case=True- ),- )- mocked_send_webhook_request.assert_called_once_with(TEST_ID)--@mock.patch("saleor.plugins.webhook.tasks.send_webhook_request_async.delay")@mock.patch("saleor.plugins.webhook.tasks.create_deliveries_for_subscriptions")def test_trigger_webhooks_async_no_subscription_webhooks(diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex 840a038af9..16588c86b9 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -5139,7 +5139,7 @@ def webhook_app(permission_manage_menus,permission_manage_products,):- app = App.objects.create(name="Sample app objects", is_active=True)+ app = App.objects.create(name="Webhook app", is_active=True)app.permissions.add(permission_manage_shipping)app.permissions.add(permission_manage_gift_card)app.permissions.add(permission_manage_discounts)diff --git a/saleor/webhook/event_types.py b/saleor/webhook/event_types.pyindex d742094b58..103ffbdb52 100644--- a/saleor/webhook/event_types.py+++ b/saleor/webhook/event_types.py@@ -339,12 +339,12 @@ class WebhookEventAsyncType:TRANSACTION_ACTION_REQUEST: PaymentPermissions.HANDLE_PAYMENTS,TRANSLATION_CREATED: SitePermissions.MANAGE_TRANSLATIONS,TRANSLATION_UPDATED: SitePermissions.MANAGE_TRANSLATIONS,- WAREHOUSE_CREATED: ProductPermissions.MANAGE_PRODUCTS,- WAREHOUSE_UPDATED: ProductPermissions.MANAGE_PRODUCTS,- WAREHOUSE_DELETED: ProductPermissions.MANAGE_PRODUCTS,VOUCHER_CREATED: DiscountPermissions.MANAGE_DISCOUNTS,VOUCHER_UPDATED: DiscountPermissions.MANAGE_DISCOUNTS,VOUCHER_DELETED: DiscountPermissions.MANAGE_DISCOUNTS,+ WAREHOUSE_CREATED: ProductPermissions.MANAGE_PRODUCTS,+ WAREHOUSE_UPDATED: ProductPermissions.MANAGE_PRODUCTS,+ WAREHOUSE_DELETED: ProductPermissions.MANAGE_PRODUCTS,OBSERVABILITY: AppPermission.MANAGE_OBSERVABILITY,}@@ -486,10 +486,10 @@ SUBSCRIBABLE_EVENTS = [WebhookEventAsyncType.TRANSACTION_ACTION_REQUEST,WebhookEventAsyncType.TRANSLATION_CREATED,WebhookEventAsyncType.TRANSLATION_UPDATED,- WebhookEventAsyncType.WAREHOUSE_CREATED,- WebhookEventAsyncType.WAREHOUSE_UPDATED,- WebhookEventAsyncType.WAREHOUSE_DELETED,WebhookEventAsyncType.VOUCHER_CREATED,WebhookEventAsyncType.VOUCHER_UPDATED,WebhookEventAsyncType.VOUCHER_DELETED,+ WebhookEventAsyncType.WAREHOUSE_CREATED,+ WebhookEventAsyncType.WAREHOUSE_UPDATED,+ WebhookEventAsyncType.WAREHOUSE_DELETED,]