Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
[SALEOR-6404] webhooks in appFetchManifest mutation
Tomasz Magulskicb7c922a28b9
diff --git a/saleor/graphql/app/mutations.py b/saleor/graphql/app/mutations.pyindex 2d9609f609..fdc6fb0696 100644--- a/saleor/graphql/app/mutations.py+++ b/saleor/graphql/app/mutations.py@@ -461,6 +461,7 @@ class AppFetchManifest(BaseMutation):token_target_url=cleaned_data.get("tokenTargetUrl"),permissions=cleaned_data.get("permissions"),extensions=cleaned_data.get("extensions", []),+ webhooks=cleaned_data.get("webhooks", []),)@classmethoddiff --git a/saleor/graphql/app/types.py b/saleor/graphql/app/types.pyindex 5b37a1ddae..a0bb047083 100644--- a/saleor/graphql/app/types.py+++ b/saleor/graphql/app/types.py@@ -13,6 +13,7 @@ from ..core.federation import federated_entity, resolve_federation_referencesfrom ..core.types import Job, ModelObjectType, NonNullList, Permissionfrom ..meta.types import ObjectWithMetadatafrom ..utils import format_permissions_for_display, get_user_or_app_from_context+from ..webhook.enums import WebhookEventTypeEnumfrom ..webhook.types import Webhookfrom .dataloaders import AppByIdLoader, AppExtensionByAppIdLoaderfrom .enums import AppExtensionMountEnum, AppExtensionTargetEnum, AppTypeEnum@@ -124,6 +125,26 @@ class AppExtensionCountableConnection(CountableConnection):node = AppExtension+class AppManifestWebhook(graphene.ObjectType):+ name = graphene.String(required=True)+ events = NonNullList(WebhookEventTypeEnum, required=True)+ query = graphene.String(required=True)+ target_url = graphene.String(required=True)+ is_active = graphene.Boolean(required=True)++ @staticmethod+ def resolve_events(root, info):+ return [WebhookEventTypeEnum[name] for name in root["events"]]++ @staticmethod+ def resolve_target_url(root, info):+ return root["targetUrl"]++ @staticmethod+ def resolve_is_active(root, info):+ return root["isActive"]++class Manifest(graphene.ObjectType):identifier = graphene.String(required=True)version = graphene.String(required=True)@@ -138,6 +159,7 @@ class Manifest(graphene.ObjectType):homepage_url = graphene.String()support_url = graphene.String()extensions = NonNullList(AppManifestExtension, required=True)+ webhooks = NonNullList(AppManifestWebhook, required=True)class Meta:description = "The manifest definition."diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 552fd843e9..499c9d8106 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -15815,6 +15815,7 @@ type Manifest {homepageUrl: StringsupportUrl: Stringextensions: [AppManifestExtension!]!+ webhooks: [AppManifestWebhook!]!}type AppManifestExtension {@@ -15834,6 +15835,14 @@ type AppManifestExtension {target: AppExtensionTargetEnum!}+type AppManifestWebhook {+ name: String!+ events: [WebhookEventTypeEnum!]!+ query: String!+ targetUrl: String!+ isActive: Boolean!+}+"""Activate the app. Requires one of the following permissions: MANAGE_APPS."""