Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add identifier field to AppExtension (#19360)
Lukasz Ostrowski4993361d39d2
diff --git a/AGENTS.md b/AGENTS.mdindex 5b1f06a4f2..bdd944c779 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -200,6 +200,35 @@ When adding or changing search vector indexing logic, create a data migration th- Task: `saleor/giftcard/migrations/tasks/saleor3_22.py`- Migration: `saleor/giftcard/migrations/0023_mark_gift_cards_search_vector_as_dirty.py`+## Adding indexes / unique constraints concurrently++Building an index synchronously (the default `AddIndex` / `AddConstraint`) takes+an `ACCESS EXCLUSIVE` lock on the whole table for the duration of the build,+blocking reads and writes. On a large table this can mean significant downtime.+Build the index `CONCURRENTLY` instead so it does not block concurrent traffic.++### Rules++- `CREATE INDEX CONCURRENTLY` cannot run inside a transaction, so the migration+ that creates it must set `atomic = False`.+- Keep the concurrent index in its **own** migration. Fast, atomic schema+ changes (`AddField`, `CheckConstraint`, etc.) stay in a normal `atomic = True`+ migration; only the slow, non-atomic index build lives on its own. This keeps+ most schema changes transactional and limits the blast radius if the+ concurrent build fails and has to be retried.+- To back a `UniqueConstraint` with a concurrently-built index, wrap the raw SQL+ in `SeparateDatabaseAndState`: `database_operations` create the index+ `CONCURRENTLY` and attach it via `ALTER TABLE ... ADD CONSTRAINT ... UNIQUE+ USING INDEX`, while `state_operations` hold the matching+ `AddConstraint(UniqueConstraint(...))` so Django's model state stays in sync.+- Always provide `reverse_sql` (use `DROP INDEX CONCURRENTLY IF EXISTS` /+ `DROP CONSTRAINT IF EXISTS`).++### Reference example++- `saleor/page/migrations/0030_slug_translation_unique_constraint.py`+- `saleor/app/migrations/0040_appextension_identifier_unique_constraint.py`+ (split out of the atomic `0039_appextension_identifier_and_more.py`)# Code stylediff --git a/saleor/app/error_codes.py b/saleor/app/error_codes.pyindex 4b38acb11c..2d7cecf2f8 100644--- a/saleor/app/error_codes.py+++ b/saleor/app/error_codes.py@@ -10,6 +10,7 @@ class AppErrorCode(Enum):INVALID_URL_FORMAT = "invalid_url_format"INVALID_MANIFEST_FORMAT = "invalid_manifest_format"INVALID_CUSTOM_HEADERS = "invalid_custom_headers"+ DUPLICATED_EXTENSION_IDENTIFIER = "duplicated_extension_identifier"MANIFEST_URL_CANT_CONNECT = "manifest_url_cant_connect"NOT_FOUND = "not_found"REQUIRED = "required"diff --git a/saleor/app/installation_utils.py b/saleor/app/installation_utils.pyindex 12fd522cca..1f53acf6b9 100644--- a/saleor/app/installation_utils.py+++ b/saleor/app/installation_utils.py@@ -273,6 +273,7 @@ def install_app(target=extension_data.get("target", DEFAULT_APP_TARGET),http_target_method=http_target_method,settings=extension_data.get("options", {}),+ identifier=extension_data.get("identifier"),)extension.permissions.set(extension_data.get("permissions", []))diff --git a/saleor/app/manifest_schema.py b/saleor/app/manifest_schema.pyindex b132c95cf2..1e8548c334 100644--- a/saleor/app/manifest_schema.py+++ b/saleor/app/manifest_schema.py@@ -11,6 +11,8 @@ from .error_codes import AppErrorCodefrom .types import DEFAULT_APP_TARGETfrom .validators import AppURLValidator, image_url_validator+EXTENSION_IDENTIFIER_MAX_LENGTH = 256+_CAMEL_CONFIG = ConfigDict(extra="ignore",populate_by_name=True,@@ -59,6 +61,30 @@ class ManifestExtensionSchema(BaseModel):target: str = DEFAULT_APP_TARGETpermissions: list[str] = []options: dict = {}+ identifier: str | None = None++ @field_validator("identifier")+ @classmethod+ def validate_identifier(cls, v: str | None) -> str | None:+ """Validate the identifier length.++ Normalization (stripping whitespace, treating blank values as not+ provided) happens later in ``manifest_validations``: the validated+ model returned by ``model_validate`` is discarded, so any value+ returned here would not reach the manifest data. Length is checked+ here because it is a purely structural constraint. The raw value is+ measured (whitespace included) since that is what would be persisted.+ """+ if v is None:+ return None+ if len(v) > EXTENSION_IDENTIFIER_MAX_LENGTH:+ raise PydanticCustomError(+ AppErrorCode.INVALID.value,+ "Identifier is too long. Maximum length is "+ f"{EXTENSION_IDENTIFIER_MAX_LENGTH} characters.",+ {"error_code": AppErrorCode.INVALID.value},+ )+ return vclass ManifestWebhookSchema(BaseModel):diff --git a/saleor/app/manifest_validations.py b/saleor/app/manifest_validations.pyindex 8a8fd35ea0..08d6a06b2e 100644--- a/saleor/app/manifest_validations.py+++ b/saleor/app/manifest_validations.py@@ -196,6 +196,7 @@ def _clean_extension_permissions(extension, app_permissions, errors):def _clean_extensions(manifest_data, app_permissions, errors):extensions = manifest_data.get("extensions", [])+ seen_identifiers: set[str] = set()for extension in extensions:if "target" not in extension:extension["target"] = DEFAULT_APP_TARGET@@ -204,6 +205,8 @@ def _clean_extensions(manifest_data, app_permissions, errors):extension["target"] = extension["target"].lower()extension["mount"] = extension["mount"].lower()+ _clean_extension_identifier(extension, seen_identifiers, errors)+try:_clean_extension_url(extension, manifest_data)except (ValidationError, AttributeError):@@ -217,6 +220,28 @@ def _clean_extensions(manifest_data, app_permissions, errors):_clean_extension_permissions(extension, app_permissions, errors)+def _clean_extension_identifier(extension, seen_identifiers, errors):+ """Normalize and ensure the extension identifier is unique within the manifest.++ Blank or whitespace-only identifiers are treated as not provided (``None``)+ and may repeat freely. Non-empty identifiers must be unique per app.+ """+ identifier = (extension.get("identifier") or "").strip() or None+ extension["identifier"] = identifier++ if identifier is None:+ return++ if identifier in seen_identifiers:+ errors["extensions"].append(+ ValidationError(+ f"Duplicate extension identifier: {identifier}.",+ code=AppErrorCode.DUPLICATED_EXTENSION_IDENTIFIER.value,+ )+ )+ seen_identifiers.add(identifier)++def _clean_webhooks(manifest_data, errors):webhooks = manifest_data.get("webhooks", [])diff --git a/saleor/app/migrations/0039_appextension_identifier_and_more.py b/saleor/app/migrations/0039_appextension_identifier_and_more.pynew file mode 100644index 0000000000..faf3cfb6c3--- /dev/null+++ b/saleor/app/migrations/0039_appextension_identifier_and_more.py@@ -0,0 +1,24 @@+# Generated by Django 5.2.15 on 2026-06-23 13:08++from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ("app", "0038_merge_20260213_1154"),+ ]++ operations = [+ migrations.AddField(+ model_name="appextension",+ name="identifier",+ field=models.CharField(max_length=256, null=True),+ ),+ migrations.AddConstraint(+ model_name="appextension",+ constraint=models.CheckConstraint(+ condition=~models.Q(identifier=""),+ name="app_extension_identifier_not_blank",+ ),+ ),+ ]diff --git a/saleor/app/migrations/0040_appextension_identifier_unique_constraint.py b/saleor/app/migrations/0040_appextension_identifier_unique_constraint.pynew file mode 100644index 0000000000..d619b23099--- /dev/null+++ b/saleor/app/migrations/0040_appextension_identifier_unique_constraint.py@@ -0,0 +1,49 @@+from django.db import migrations, models+++class Migration(migrations.Migration):+ # The unique index is built CONCURRENTLY so it does not hold an ACCESS+ # EXCLUSIVE lock on app_appextension while it is created. CONCURRENTLY+ # cannot run inside a transaction, hence atomic = False and its own+ # migration, separate from the fast, atomic schema changes in 0039.+ atomic = False++ dependencies = [+ ("app", "0039_appextension_identifier_and_more"),+ ]++ operations = [+ migrations.SeparateDatabaseAndState(+ database_operations=[+ migrations.RunSQL(+ sql="""+ CREATE UNIQUE INDEX CONCURRENTLY unique_app_extension_identifier+ ON app_appextension ("app_id", "identifier");+ """,+ reverse_sql="""+ DROP INDEX CONCURRENTLY IF EXISTS unique_app_extension_identifier;+ """,+ ),+ migrations.RunSQL(+ sql="""+ ALTER TABLE app_appextension+ ADD CONSTRAINT unique_app_extension_identifier+ UNIQUE USING INDEX unique_app_extension_identifier;+ """,+ reverse_sql="""+ ALTER TABLE app_appextension DROP CONSTRAINT+ IF EXISTS unique_app_extension_identifier;+ """,+ ),+ ],+ state_operations=[+ migrations.AddConstraint(+ model_name="appextension",+ constraint=models.UniqueConstraint(+ fields=("app", "identifier"),+ name="unique_app_extension_identifier",+ ),+ ),+ ],+ ),+ ]diff --git a/saleor/app/migrations/0041_merge_20260714_1040.py b/saleor/app/migrations/0041_merge_20260714_1040.pynew file mode 100644index 0000000000..18443f954c--- /dev/null+++ b/saleor/app/migrations/0041_merge_20260714_1040.py@@ -0,0 +1,12 @@+# Generated by Django 5.2.15 on 2026-07-14 10:40++from django.db import migrations+++class Migration(migrations.Migration):+ dependencies = [+ ("app", "0039_remove_manage_apps_permission"),+ ("app", "0040_appextension_identifier_unique_constraint"),+ ]++ operations = []diff --git a/saleor/app/models.py b/saleor/app/models.pyindex 29fde4f86f..b95cfc2373 100644--- a/saleor/app/models.py+++ b/saleor/app/models.py@@ -172,6 +172,19 @@ class AppExtension(models.Model):choices=DeprecatedAppExtensionHttpMethod.CHOICES,)settings = models.JSONField(blank=True, default=dict, db_default={})+ identifier = models.CharField(max_length=256, null=True)++ class Meta:+ constraints = [+ models.UniqueConstraint(+ fields=["app", "identifier"],+ name="unique_app_extension_identifier",+ ),+ models.CheckConstraint(+ condition=~models.Q(identifier=""),+ name="app_extension_identifier_not_blank",+ ),+ ]class AppProblem(models.Model):diff --git a/saleor/app/tests/test_installation_utils.py b/saleor/app/tests/test_installation_utils.pyindex 06cc3f695c..465f1d74e5 100644--- a/saleor/app/tests/test_installation_utils.py+++ b/saleor/app/tests/test_installation_utils.py@@ -309,6 +309,61 @@ def test_install_app_with_extension(assert app_extension.http_target_method is None+def test_install_app_with_extension_identifier(+ app_manifest,+ app_installation,+ monkeypatch,+):+ # given+ identifier = "refund-button"+ app_manifest["extensions"] = [+ {+ "label": "Create product with app",+ "url": "https://example.com/app-extension",+ "mount": "PRODUCT_OVERVIEW_CREATE",+ "identifier": identifier,+ }+ ]+ mocked_get_response = Mock()+ mocked_get_response.json.return_value = app_manifest+ monkeypatch.setattr(HTTPSession, "request", Mock(return_value=mocked_get_response))+ monkeypatch.setattr("saleor.app.installation_utils.send_app_token", Mock())++ # when+ app, _ = install_app(app_installation, activate=True)++ # then+ app_extension = app.extensions.get()+ assert app_extension.identifier == identifier+++def test_install_app_with_extension_blank_identifier_stored_as_none(+ app_manifest,+ app_installation,+ monkeypatch,+):+ # given+ app_manifest["extensions"] = [+ {+ "label": "Create product with app",+ "url": "https://example.com/app-extension",+ "mount": "PRODUCT_OVERVIEW_CREATE",+ "identifier": " ",+ }+ ]+ mocked_get_response = Mock()+ mocked_get_response.json.return_value = app_manifest+ monkeypatch.setattr(HTTPSession, "request", Mock(return_value=mocked_get_response))+ monkeypatch.setattr("saleor.app.installation_utils.send_app_token", Mock())++ # when+ app, _ = install_app(app_installation, activate=True)++ # then+ app_extension = app.extensions.get()+ assert app_extension.identifier is None++def test_install_app_with_extension_widget(app_manifest,app_installation,diff --git a/saleor/app/tests/test_manifest_validations.py b/saleor/app/tests/test_manifest_validations.pyindex f790803399..1d3fe74282 100644--- a/saleor/app/tests/test_manifest_validations.py+++ b/saleor/app/tests/test_manifest_validations.py@@ -4,7 +4,12 @@ from pydantic import ValidationError as PydanticValidationErrorfrom ...permission.enums import AppPermission, ProductPermissionsfrom ..error_codes import AppErrorCode-from ..manifest_schema import ICON_MIME_TYPES, ManifestSchema+from ..manifest_schema import (+ EXTENSION_IDENTIFIER_MAX_LENGTH,+ ICON_MIME_TYPES,+ ManifestExtensionSchema,+ ManifestSchema,+)from ..manifest_validations import clean_manifest_dataMINIMAL_MANIFEST = {@@ -419,6 +424,188 @@ def test_clean_manifest_data_rejects_manage_apps_permission_on_extension_alongsiassert error.params == {"permissions": [manage_apps], "label": extension_label}+def _extension(label, identifier=None):+ extension = {+ "label": label,+ "url": "https://example.com/ext",+ "mount": "PRODUCT_OVERVIEW_MORE_ACTIONS",+ "target": "POPUP",+ }+ if identifier is not None:+ extension["identifier"] = identifier+ return extension+++def test_clean_manifest_data_accepts_unique_extension_identifiers():+ # given - two extensions with distinct identifiers+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [+ _extension("First", identifier="first-ext"),+ _extension("Second", identifier="second-ext"),+ ],+ }++ # when+ clean_manifest_data(manifest_data)++ # then - identifiers are preserved on the cleaned manifest+ assert manifest_data["extensions"][0]["identifier"] == "first-ext"+ assert manifest_data["extensions"][1]["identifier"] == "second-ext"+++def test_clean_manifest_data_rejects_duplicate_extension_identifiers():+ # given - two extensions reuse the same identifier within one manifest+ duplicate_identifier = "refund-button"+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [+ _extension("First", identifier=duplicate_identifier),+ _extension("Second", identifier=duplicate_identifier),+ ],+ }++ # when+ with pytest.raises(ValidationError) as exc_info:+ clean_manifest_data(manifest_data)++ # then+ extension_errors = exc_info.value.error_dict["extensions"]+ assert len(extension_errors) == 1+ error = extension_errors[0]+ assert error.code == AppErrorCode.DUPLICATED_EXTENSION_IDENTIFIER.value+ assert duplicate_identifier in error.message+++def test_clean_manifest_data_allows_multiple_extensions_without_identifier():+ # given - several extensions omit the identifier entirely+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [+ _extension("First"),+ _extension("Second"),+ ],+ }++ # when+ clean_manifest_data(manifest_data)++ # then - absent identifiers are normalized to None and do not collide+ assert manifest_data["extensions"][0]["identifier"] is None+ assert manifest_data["extensions"][1]["identifier"] is None+++def test_clean_manifest_data_coerces_blank_identifier_to_none():+ # given - blank and whitespace-only identifiers+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [+ _extension("First", identifier=" "),+ _extension("Second", identifier=""),+ ],+ }++ # when+ clean_manifest_data(manifest_data)++ # then - both are treated as not provided, so no duplicate error is raised+ assert manifest_data["extensions"][0]["identifier"] is None+ assert manifest_data["extensions"][1]["identifier"] is None+++def test_clean_manifest_data_strips_surrounding_whitespace_from_identifier():+ # given - identifier padded with whitespace+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [_extension("First", identifier=" refund-button ")],+ }++ # when+ clean_manifest_data(manifest_data)++ # then+ assert manifest_data["extensions"][0]["identifier"] == "refund-button"+++def test_clean_manifest_data_accepts_identifier_at_max_length():+ # given - identifier exactly at the maximum allowed length+ identifier = "a" * EXTENSION_IDENTIFIER_MAX_LENGTH+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [_extension("First", identifier=identifier)],+ }++ # when+ clean_manifest_data(manifest_data)++ # then+ assert manifest_data["extensions"][0]["identifier"] == identifier+++def test_clean_manifest_data_rejects_too_long_identifier():+ # given - identifier exceeding the maximum allowed length+ identifier = "a" * (EXTENSION_IDENTIFIER_MAX_LENGTH + 1)+ manifest_data = {+ **MINIMAL_MANIFEST,+ "extensions": [_extension("First", identifier=identifier)],+ }++ # when+ with pytest.raises(ValidationError) as exc_info:+ clean_manifest_data(manifest_data)++ # then+ expected_message = (+ f"Identifier is too long. Maximum length is "+ f"{EXTENSION_IDENTIFIER_MAX_LENGTH} characters."+ )+ extension_errors = exc_info.value.error_dict["extensions"]+ assert len(extension_errors) == 1+ error = extension_errors[0]+ assert error.code == AppErrorCode.INVALID.value+ assert error.message == expected_message+++def test_manifest_extension_schema_rejects_too_long_identifier():+ # given - identifier exceeding the maximum allowed length+ identifier = "a" * (EXTENSION_IDENTIFIER_MAX_LENGTH + 1)+ extension_data = _extension("First", identifier=identifier)++ # when+ with pytest.raises(PydanticValidationError) as exc_info:+ ManifestExtensionSchema.model_validate(extension_data)++ # then+ expected_message = (+ f"Identifier is too long. Maximum length is "+ f"{EXTENSION_IDENTIFIER_MAX_LENGTH} characters."+ )+ errors = exc_info.value.errors()+ assert len(errors) == 1+ assert errors[0]["loc"] == ("identifier",)+ assert errors[0]["msg"] == expected_message+ assert errors[0]["ctx"]["error_code"] == AppErrorCode.INVALID.value+++def test_manifest_extension_schema_accepts_identifier_at_max_length():+ # given - identifier exactly at the maximum allowed length+ identifier = "a" * EXTENSION_IDENTIFIER_MAX_LENGTH+ extension_data = _extension("First", identifier=identifier)++ # when+ schema = ManifestExtensionSchema.model_validate(extension_data)++ # then+ assert schema.identifier == identifier++def test_manifest_schema_deprecated_fields_accepted():# given — deprecated fields are excluded from schema but must not cause a# validation error, and must remain accessible in the original dict so thatdiff --git a/saleor/app/tests/test_models.py b/saleor/app/tests/test_models.pyindex e8fa521098..f600ebe5a8 100644--- a/saleor/app/tests/test_models.py+++ b/saleor/app/tests/test_models.py@@ -1,6 +1,10 @@+import pytest+from django.db import IntegrityError+from django.db.transaction import atomic+from ...app.models import Appfrom ...webhook.event_types import WebhookEventSyncType-from ..models import AppInstallation+from ..models import AppExtension, AppInstallationdef test_qs_for_event_type(payment_app):@@ -40,6 +44,85 @@ def test_qs_for_event_type_inactive_webhook(payment_app):assert len(qs) == 0+def test_app_extension_identifier_must_be_unique_per_app(app):+ # given+ identifier = "refund-button"+ AppExtension.objects.create(+ app=app,+ label="Extension",+ url="https://example.com/ext",+ mount="product_overview_more_actions",+ identifier=identifier,+ )++ # when / then - reusing the identifier within the same app is rejected+ with pytest.raises(IntegrityError), atomic():+ AppExtension.objects.create(+ app=app,+ label="Other extension",+ url="https://example.com/ext-2",+ mount="product_details_more_actions",+ identifier=identifier,+ )+++def test_app_extension_identifier_can_be_reused_across_apps(app):+ # given+ identifier = "refund-button"+ other_app = App.objects.create(name="Other app")+ AppExtension.objects.create(+ app=app,+ label="Extension",+ url="https://example.com/ext",+ mount="product_overview_more_actions",+ identifier=identifier,+ )++ # when - a different app uses the same identifier+ extension = AppExtension.objects.create(+ app=other_app,+ label="Extension",+ url="https://example.com/ext",+ mount="product_overview_more_actions",+ identifier=identifier,+ )++ # then+ assert extension.identifier == identifier+++def test_app_extension_allows_multiple_null_identifiers_per_app(app):+ # given / when - two extensions of the same app omit the identifier+ first = AppExtension.objects.create(+ app=app,+ label="Extension",+ url="https://example.com/ext",+ mount="product_overview_more_actions",+ )+ second = AppExtension.objects.create(+ app=app,+ label="Other extension",+ url="https://example.com/ext-2",+ mount="product_details_more_actions",+ )++ # then - NULL identifiers are exempt from the uniqueness constraint+ assert first.identifier is None+ assert second.identifier is None+++def test_app_extension_identifier_cannot_be_blank(app):+ # given / when / then - a blank identifier is rejected at the database level+ with pytest.raises(IntegrityError), atomic():+ AppExtension.objects.create(+ app=app,+ label="Extension",+ url="https://example.com/ext",+ mount="product_overview_more_actions",+ identifier="",+ )++def test_app_installation_set_message_truncates(app_installation):max_length = AppInstallation._meta.get_field("message").max_lengthtoo_long_message = "msg" * max_lengthdiff --git a/saleor/graphql/app/tests/mutations/test_app_fetch_manifest.py b/saleor/graphql/app/tests/mutations/test_app_fetch_manifest.pyindex adb1fcd242..44158b1753 100644--- a/saleor/graphql/app/tests/mutations/test_app_fetch_manifest.py+++ b/saleor/graphql/app/tests/mutations/test_app_fetch_manifest.py@@ -47,6 +47,7 @@ mutation AppFetchManifest(mountNametargetNamesettings+ identifierpermissions{codename@@ -527,6 +528,44 @@ def test_app_fetch_manifest_with_extensions(assert extension["targetName"] == "POPUP"assert extension["settings"] == {}+ assert extension["identifier"] is None+++def test_app_fetch_manifest_with_extension_identifier(+ staff_api_client, app_manifest, permission_manage_apps, monkeypatch+):+ # given+ manifest_url = "http://localhost:3000/manifest"+ identifier = "refund-button"++ app_manifest["extensions"] = [+ {+ "label": "Create product with App",+ "url": "http://127.0.0.1:8080/app",+ "mount": "PRODUCT_OVERVIEW_CREATE",+ "identifier": identifier,+ }+ ]++ mocked_get_response = Mock()+ mocked_get_response.json.return_value = app_manifest+ monkeypatch.setattr(HTTPSession, "request", Mock(return_value=mocked_get_response))++ variables = {"manifest_url": manifest_url}++ # when+ response = staff_api_client.post_graphql(+ APP_FETCH_MANIFEST_MUTATION,+ variables=variables,+ permissions=[permission_manage_apps],+ )++ # then+ content = get_graphql_content(response)+ assert not content["data"]["appFetchManifest"]["errors"]+ extensions = content["data"]["appFetchManifest"]["manifest"]["extensions"]+ assert len(extensions) == 1+ assert extensions[0]["identifier"] == identifierdef test_app_fetch_manifest_with_widget_extension_settings(diff --git a/saleor/graphql/app/tests/queries/test_app_extension.py b/saleor/graphql/app/tests/queries/test_app_extension.pyindex 7f979fbfd5..b891c76807 100644--- a/saleor/graphql/app/tests/queries/test_app_extension.py+++ b/saleor/graphql/app/tests/queries/test_app_extension.py@@ -626,6 +626,64 @@ def test_app_extension_type_settings_from_http_target_method(assert extension_data["settings"]["widgetTarget"]["method"] == method+QUERY_APP_EXTENSION_IDENTIFIER = """+query ($id: ID!){+ appExtension(id: $id){+ id+ identifier+ }+}+"""+++def test_app_extension_identifier_returned(app, staff_api_client):+ # given+ identifier = "refund-button"+ app_extension = AppExtension.objects.create(+ app=app,+ label="Create product with App",+ url="https://www.example.com/app-product",+ mount="product_overview_more_actions",+ identifier=identifier,+ )+ id = graphene.Node.to_global_id("AppExtension", app_extension.id)+ variables = {"id": id}++ # when+ response = staff_api_client.post_graphql(+ QUERY_APP_EXTENSION_IDENTIFIER,+ variables,+ )++ # then+ content = get_graphql_content(response)+ extension_data = content["data"]["appExtension"]+ assert extension_data["identifier"] == identifier+++def test_app_extension_identifier_null_when_not_set(app, staff_api_client):+ # given+ app_extension = AppExtension.objects.create(+ app=app,+ label="Create product with App",+ url="https://www.example.com/app-product",+ mount="product_overview_more_actions",+ )+ id = graphene.Node.to_global_id("AppExtension", app_extension.id)+ variables = {"id": id}++ # when+ response = staff_api_client.post_graphql(+ QUERY_APP_EXTENSION_IDENTIFIER,+ variables,+ )++ # then+ content = get_graphql_content(response)+ extension_data = content["data"]["appExtension"]+ assert extension_data["identifier"] is None++def test_app_extension_type_settings_from_native_settings(app,staff_api_client,diff --git a/saleor/graphql/app/types.py b/saleor/graphql/app/types.pyindex 8ad62c457c..8168f4e844 100644--- a/saleor/graphql/app/types.py+++ b/saleor/graphql/app/types.py@@ -32,7 +32,7 @@ from ..core import ResolveInfo, SaleorContextfrom ..core.connection import CountableConnectionfrom ..core.context import get_database_connection_namefrom ..core.dataloaders import DataLoader-from ..core.descriptions import ADDED_IN_322+from ..core.descriptions import ADDED_IN_322, ADDED_IN_323from ..core.doc_category import DOC_CATEGORY_APPSfrom ..core.federation import federated_entity, resolve_federation_referencesfrom ..core.fields import PermissionsField@@ -143,6 +143,13 @@ class AppManifestExtension(BaseObjectType):required=True,)+ identifier = graphene.String(+ description=(+ "Extension identifier, unique per app. Null when the app does not "+ "declare one." + ADDED_IN_323+ )+ )+class Meta:doc_category = DOC_CATEGORY_APPSdiff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 06d3178fff..993507d2bc 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -3105,6 +3105,13 @@ type AppExtension implements Node @doc(category: "Apps") {"""settings: JSON!+ """+ Extension identifier, unique per app. Null when the app does not declare one.++ Added in Saleor 3.23.+ """+ identifier: String+"""The app assigned to app extension."""app: App!@@ -32107,6 +32114,7 @@ enum AppErrorCode @doc(category: "Apps") {INVALID_URL_FORMATINVALID_MANIFEST_FORMATINVALID_CUSTOM_HEADERS+ DUPLICATED_EXTENSION_IDENTIFIERMANIFEST_URL_CANT_CONNECTNOT_FOUNDREQUIRED@@ -32348,6 +32356,13 @@ type AppManifestExtension @doc(category: "Apps") {Added in Saleor 3.22."""settings: JSON!++ """+ Extension identifier, unique per app. Null when the app does not declare one.++ Added in Saleor 3.23.+ """+ identifier: String}type AppManifestWebhook @doc(category: "Apps") {