Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix: Cannot return null for non-nullable field Webhook.name. (#13074)
Smit Parmar1f9b5c53a63a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cca5d813e3..46d2b98168 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,7 @@ All notable, unreleased changes to this project will be documented in this file.### Other changes- Expand metric units to support more types of products. - #13043 by @FremahA+- Fix Error Cannot return null for non-nullable field Webhook.name. - #12989 by @cyborg7898# 3.14.0diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 26d95cbc5d..6942d39169 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -1609,7 +1609,7 @@ type Query {"""Webhook."""type Webhook implements Node @doc(category: "Webhooks") {id: ID!- name: String!+ name: String"""List of webhook events."""events: [WebhookEvent!]! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `asyncEvents` or `syncEvents` instead.")diff --git a/saleor/graphql/webhook/tests/queries/test_webhook.py b/saleor/graphql/webhook/tests/queries/test_webhook.pyindex aa0a379b4e..73d6ebd898 100644--- a/saleor/graphql/webhook/tests/queries/test_webhook.py+++ b/saleor/graphql/webhook/tests/queries/test_webhook.py@@ -14,6 +14,7 @@ QUERY_WEBHOOK = """webhook(id: $id) {idisActive+ namesubscriptionQueryasyncEvents {eventType@@ -167,3 +168,18 @@ def test_webhook_with_invalid_object_type(response = staff_api_client.post_graphql(QUERY_WEBHOOK, variables)content = get_graphql_content(response)assert content["data"]["webhook"] is None+++def test_webhook_without_name(+ staff_api_client, webhook_without_name, permission_manage_apps+):+ query = QUERY_WEBHOOK+ webhook_id = graphene.Node.to_global_id("Webhook", webhook_without_name.pk)+ variables = {"id": webhook_id}+ staff_api_client.user.user_permissions.add(permission_manage_apps)+ response = staff_api_client.post_graphql(query, variables=variables)+ content = get_graphql_content(response)+ webhook_response = content["data"]["webhook"]+ assert webhook_response["name"] is None+ events = webhook_without_name.events.all()+ assert len(events) == 1diff --git a/saleor/graphql/webhook/types.py b/saleor/graphql/webhook/types.pyindex 0a6d0abb8c..a14ba7b250 100644--- a/saleor/graphql/webhook/types.py+++ b/saleor/graphql/webhook/types.py@@ -147,7 +147,7 @@ class EventDeliveryCountableConnection(CountableConnection):class Webhook(ModelObjectType[models.Webhook]):id = graphene.GlobalID(required=True)- name = graphene.String(required=True)+ name = graphene.String(required=False)events = NonNullList(WebhookEvent,description="List of webhook events.",diff --git a/saleor/tests/fixtures.py b/saleor/tests/fixtures.pyindex 640f929692..7465551318 100644--- a/saleor/tests/fixtures.py+++ b/saleor/tests/fixtures.py@@ -6294,6 +6294,13 @@ def webhook(app):return webhook+def webhook_without_name(app):+ webhook = Webhook.objects.create(app=app, target_url="http://www.example.com/test")+ webhook.events.create(event_type=WebhookEventAsyncType.ORDER_CREATED)+ return webhook++@pytest.fixturedef any_webhook(app):webhook = Webhook.objects.create(