Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Deprecate remaining API surface of the storefront attributes presentation (#19671)
Lukasz Ostrowski86491944365b
diff --git a/saleor/graphql/attribute/descriptions.py b/saleor/graphql/attribute/descriptions.pyindex 7a938fd06b..bc52fc420c 100644--- a/saleor/graphql/attribute/descriptions.py+++ b/saleor/graphql/attribute/descriptions.py@@ -1,5 +1,15 @@from ..core.descriptions import RICH_CONTENT+STOREFRONT_FLAG_DEPRECATION_REASON = (+ "This flag is not used by Saleor. Keep the logic in the storefront or use "+ "`Attribute` metadata instead."+)++DASHBOARD_FLAG_DEPRECATION_REASON = (+ "This flag is not used by Saleor. Keep the logic in the dashboard or use "+ "`Attribute` metadata instead."+)+class AttributeDescriptions:INPUT_TYPE = "The input type to use for entering attribute values in the dashboard."diff --git a/saleor/graphql/attribute/filters.py b/saleor/graphql/attribute/filters.pyindex f04d20cbfd..27ca29184d 100644--- a/saleor/graphql/attribute/filters.py+++ b/saleor/graphql/attribute/filters.py@@ -11,6 +11,7 @@ from ...permission.utils import has_one_of_permissionsfrom ...product import models as product_modelsfrom ...product.models import ALL_PRODUCTS_PERMISSIONSfrom ..channel.filters import get_channel_slug_from_filter_data+from ..core.descriptions import DEPRECATED_IN_3X_INPUTfrom ..core.doc_category import DOC_CATEGORY_ATTRIBUTESfrom ..core.enums import MeasurementUnitsEnumfrom ..core.filters import (@@ -38,6 +39,11 @@ from ..core.types.common import NonNullListfrom ..core.utils import from_global_id_or_errorfrom ..utils import get_user_or_app_from_contextfrom ..utils.filters import filter_by_ids, filter_slug_list, filter_where_by_value_field+from .descriptions import (+ DASHBOARD_FLAG_DEPRECATION_REASON,+ STOREFRONT_FLAG_DEPRECATION_REASON,+ AttributeDescriptions,+)from .enums import AttributeEntityTypeEnum, AttributeInputTypeEnum, AttributeTypeEnum@@ -136,6 +142,24 @@ class AttributeFilter(MetadataFilterBase):in_collection = GlobalIDFilter(method="filter_in_collection")in_category = GlobalIDFilter(method="filter_in_category")slugs = ListObjectTypeFilter(input_class=graphene.String, method=filter_slug_list)+ filterable_in_storefront = django_filters.BooleanFilter(+ help_text=(+ f"{AttributeDescriptions.FILTERABLE_IN_STOREFRONT}"+ f"{DEPRECATED_IN_3X_INPUT} {STOREFRONT_FLAG_DEPRECATION_REASON}"+ )+ )+ available_in_grid = django_filters.BooleanFilter(+ help_text=(+ f"{AttributeDescriptions.AVAILABLE_IN_GRID}"+ f"{DEPRECATED_IN_3X_INPUT} {STOREFRONT_FLAG_DEPRECATION_REASON}"+ )+ )+ filterable_in_dashboard = django_filters.BooleanFilter(+ help_text=(+ f"{AttributeDescriptions.FILTERABLE_IN_DASHBOARD}"+ f"{DEPRECATED_IN_3X_INPUT} {DASHBOARD_FLAG_DEPRECATION_REASON}"+ )+ )class Meta:model = Attribute@@ -143,9 +167,6 @@ class AttributeFilter(MetadataFilterBase):"value_required","is_variant_only","visible_in_storefront",- "filterable_in_storefront",- "filterable_in_dashboard",- "available_in_grid",]def filter_in_collection(self, qs, name, value):@@ -288,7 +309,12 @@ class AttributeWhere(MetadataWhereFilterBase):in_category = GlobalIDWhereFilter(method="filter_in_category")value_required = BooleanWhereFilter()visible_in_storefront = BooleanWhereFilter()- filterable_in_dashboard = BooleanWhereFilter()+ filterable_in_dashboard = BooleanWhereFilter(+ help_text=(+ f"{AttributeDescriptions.FILTERABLE_IN_DASHBOARD}"+ f"{DEPRECATED_IN_3X_INPUT} {DASHBOARD_FLAG_DEPRECATION_REASON}"+ )+ )class Meta:model = Attributediff --git a/saleor/graphql/attribute/mutations/attribute_create.py b/saleor/graphql/attribute/mutations/attribute_create.pyindex 94d26ff811..e0adaf4ad0 100644--- a/saleor/graphql/attribute/mutations/attribute_create.py+++ b/saleor/graphql/attribute/mutations/attribute_create.py@@ -15,7 +15,12 @@ from ...core.mutations import DeprecatedModelMutationfrom ...core.types import AttributeError, BaseInputObjectType, NonNullListfrom ...core.utils import WebhookEventInfofrom ...plugins.dataloaders import get_plugin_manager_promise-from ..descriptions import AttributeDescriptions, AttributeValueDescriptions+from ..descriptions import (+ DASHBOARD_FLAG_DEPRECATION_REASON,+ STOREFRONT_FLAG_DEPRECATION_REASON,+ AttributeDescriptions,+ AttributeValueDescriptions,+)from ..enums import AttributeEntityTypeEnum, AttributeInputTypeEnum, AttributeTypeEnumfrom ..types import Attributefrom .mixins import REFERENCE_TYPES_LIMIT, AttributeMixin@@ -77,18 +82,28 @@ class AttributeCreateInput(BaseInputObjectType):filterable_in_storefront = graphene.Boolean(description=AttributeDescriptions.FILTERABLE_IN_STOREFRONT+ DEPRECATED_IN_3X_INPUT+ + " "+ + STOREFRONT_FLAG_DEPRECATION_REASON)filterable_in_dashboard = graphene.Boolean(description=AttributeDescriptions.FILTERABLE_IN_DASHBOARD+ + DEPRECATED_IN_3X_INPUT+ + " "+ + DASHBOARD_FLAG_DEPRECATION_REASON)storefront_search_position = graphene.Int(required=False,description=AttributeDescriptions.STOREFRONT_SEARCH_POSITION- + DEPRECATED_IN_3X_INPUT,+ + DEPRECATED_IN_3X_INPUT+ + " "+ + STOREFRONT_FLAG_DEPRECATION_REASON,)available_in_grid = graphene.Boolean(required=False,- description=AttributeDescriptions.AVAILABLE_IN_GRID + DEPRECATED_IN_3X_INPUT,+ description=AttributeDescriptions.AVAILABLE_IN_GRID+ + DEPRECATED_IN_3X_INPUT+ + " "+ + STOREFRONT_FLAG_DEPRECATION_REASON,)external_reference = graphene.String(description="External ID of this attribute.", required=Falsediff --git a/saleor/graphql/attribute/mutations/attribute_update.py b/saleor/graphql/attribute/mutations/attribute_update.pyindex 456d4d2d74..f7f016b799 100644--- a/saleor/graphql/attribute/mutations/attribute_update.py+++ b/saleor/graphql/attribute/mutations/attribute_update.py@@ -17,7 +17,12 @@ from ...core.mutations import ModelWithExtRefMutationfrom ...core.types import AttributeError, BaseInputObjectType, NonNullListfrom ...core.utils import WebhookEventInfofrom ...plugins.dataloaders import get_plugin_manager_promise-from ..descriptions import AttributeDescriptions, AttributeValueDescriptions+from ..descriptions import (+ DASHBOARD_FLAG_DEPRECATION_REASON,+ STOREFRONT_FLAG_DEPRECATION_REASON,+ AttributeDescriptions,+ AttributeValueDescriptions,+)from ..types import Attributefrom .attribute_create import AttributeValueInputfrom .mixins import REFERENCE_TYPES_LIMIT, AttributeMixin@@ -62,18 +67,28 @@ class AttributeUpdateInput(BaseInputObjectType):filterable_in_storefront = graphene.Boolean(description=AttributeDescriptions.FILTERABLE_IN_STOREFRONT+ DEPRECATED_IN_3X_INPUT+ + " "+ + STOREFRONT_FLAG_DEPRECATION_REASON)filterable_in_dashboard = graphene.Boolean(description=AttributeDescriptions.FILTERABLE_IN_DASHBOARD+ + DEPRECATED_IN_3X_INPUT+ + " "+ + DASHBOARD_FLAG_DEPRECATION_REASON)storefront_search_position = graphene.Int(required=False,description=AttributeDescriptions.STOREFRONT_SEARCH_POSITION- + DEPRECATED_IN_3X_INPUT,+ + DEPRECATED_IN_3X_INPUT+ + " "+ + STOREFRONT_FLAG_DEPRECATION_REASON,)available_in_grid = graphene.Boolean(required=False,- description=AttributeDescriptions.AVAILABLE_IN_GRID + DEPRECATED_IN_3X_INPUT,+ description=AttributeDescriptions.AVAILABLE_IN_GRID+ + DEPRECATED_IN_3X_INPUT+ + " "+ + STOREFRONT_FLAG_DEPRECATION_REASON,)external_reference = graphene.String(description="External ID of this product.", required=Falsediff --git a/saleor/graphql/attribute/sorters.py b/saleor/graphql/attribute/sorters.pyindex d0f32c8fa0..515b6e0ead 100644--- a/saleor/graphql/attribute/sorters.py+++ b/saleor/graphql/attribute/sorters.py@@ -1,5 +1,9 @@from ..core.doc_category import DOC_CATEGORY_ATTRIBUTESfrom ..core.types import BaseEnum, SortInputObjectType+from .descriptions import (+ DASHBOARD_FLAG_DEPRECATION_REASON,+ STOREFRONT_FLAG_DEPRECATION_REASON,+)class AttributeSortField(BaseEnum):@@ -49,6 +53,17 @@ class AttributeSortField(BaseEnum):return descriptions[self.name]raise ValueError(f"Unsupported enum value: {self.value}")+ @property+ def deprecation_reason(self):+ # pylint: disable=no-member+ deprecations = {+ AttributeSortField.FILTERABLE_IN_STOREFRONT.name: STOREFRONT_FLAG_DEPRECATION_REASON, # type: ignore[attr-defined] # graphene.Enum is not typed # noqa: E501+ AttributeSortField.STOREFRONT_SEARCH_POSITION.name: STOREFRONT_FLAG_DEPRECATION_REASON, # type: ignore[attr-defined] # graphene.Enum is not typed # noqa: E501+ AttributeSortField.AVAILABLE_IN_GRID.name: STOREFRONT_FLAG_DEPRECATION_REASON, # type: ignore[attr-defined] # graphene.Enum is not typed # noqa: E501+ AttributeSortField.FILTERABLE_IN_DASHBOARD.name: DASHBOARD_FLAG_DEPRECATION_REASON, # type: ignore[attr-defined] # graphene.Enum is not typed # noqa: E501+ }+ return deprecations.get(self.name)+class AttributeSortingInput(SortInputObjectType):class Meta:diff --git a/saleor/graphql/attribute/tests/queries/test_attribute_filter.py b/saleor/graphql/attribute/tests/queries/test_attribute_filter.pyindex 1dbb8aed19..723b7b8610 100644--- a/saleor/graphql/attribute/tests/queries/test_attribute_filter.py+++ b/saleor/graphql/attribute/tests/queries/test_attribute_filter.py@@ -122,6 +122,23 @@ def test_filter_attributes_if_available_in_grid(assert attributes[0]["node"]["slug"] == "size"+def test_filter_attributes_if_filterable_in_storefront(+ api_client, color_attribute, size_attribute+):+ color_attribute.filterable_in_storefront = False+ color_attribute.save(update_fields=["filterable_in_storefront"])+ assert size_attribute.filterable_in_storefront is True++ variables = {"filters": {"filterableInStorefront": True}}++ attributes = get_graphql_content(+ api_client.post_graphql(ATTRIBUTES_FILTER_QUERY, variables)+ )["data"]["attributes"]["edges"]++ assert len(attributes) == 1+ assert attributes[0]["node"]["slug"] == size_attribute.slug++def test_filter_attributes_by_global_id_list(api_client, product_type_attribute_list):global_ids = [graphene.Node.to_global_id("Attribute", attribute.pk)diff --git a/saleor/graphql/attribute/types.py b/saleor/graphql/attribute/types.pyindex 6ae2167d8f..54b2000e38 100644--- a/saleor/graphql/attribute/types.py+++ b/saleor/graphql/attribute/types.py@@ -27,7 +27,6 @@ from ..core.context import ()from ..core.descriptions import (ADDED_IN_322,- DEFAULT_DEPRECATION_REASON,DEPRECATED_IN_3X_INPUT,NESTED_QUERY_LIMIT_DESCRIPTION,)@@ -73,7 +72,12 @@ from .dataloaders.reference_types import (AttributeReferencePageTypesByAttributeIdAndLimitLoader,AttributeReferenceProductTypesByAttributeIdAndLimitLoader,)-from .descriptions import AttributeDescriptions, AttributeValueDescriptions+from .descriptions import (+ DASHBOARD_FLAG_DEPRECATION_REASON,+ STOREFRONT_FLAG_DEPRECATION_REASON,+ AttributeDescriptions,+ AttributeValueDescriptions,+)from .enums import AttributeEntityTypeEnum, AttributeInputTypeEnum, AttributeTypeEnumfrom .filters import (AttributeValueFilterInput,@@ -346,7 +350,7 @@ class Attribute(ChannelContextType[models.Attribute]):f"{ProductTypePermissions.MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.name}."),required=True,- deprecation_reason=DEFAULT_DEPRECATION_REASON,+ deprecation_reason=STOREFRONT_FLAG_DEPRECATION_REASON,)filterable_in_dashboard = graphene.Boolean(description=(@@ -357,6 +361,7 @@ class Attribute(ChannelContextType[models.Attribute]):f"{ProductTypePermissions.MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.name}."),required=True,+ deprecation_reason=DASHBOARD_FLAG_DEPRECATION_REASON,)available_in_grid = graphene.Boolean(description=(@@ -367,7 +372,7 @@ class Attribute(ChannelContextType[models.Attribute]):f"{ProductTypePermissions.MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.name}."),required=True,- deprecation_reason=DEFAULT_DEPRECATION_REASON,+ deprecation_reason=STOREFRONT_FLAG_DEPRECATION_REASON,)storefront_search_position = graphene.Int(description=(@@ -378,7 +383,7 @@ class Attribute(ChannelContextType[models.Attribute]):f"{ProductTypePermissions.MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES.name}."),required=True,- deprecation_reason=DEFAULT_DEPRECATION_REASON,+ deprecation_reason=STOREFRONT_FLAG_DEPRECATION_REASON,)translation = TranslationField(AttributeTranslation,diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 7fc40ed83a..e490c09b0a 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -3711,22 +3711,22 @@ type Attribute implements Node & ObjectWithMetadata @doc(category: "Attributes")"""Whether the attribute can be filtered in storefront. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES."""- filterableInStorefront: Boolean! @deprecated+ filterableInStorefront: Boolean! @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Whether the attribute can be filtered in dashboard. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES."""- filterableInDashboard: Boolean!+ filterableInDashboard: Boolean! @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the dashboard or use `Attribute` metadata instead.")"""Whether the attribute can be displayed in the admin product list. Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES."""- availableInGrid: Boolean! @deprecated+ availableInGrid: Boolean! @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""The position of the attribute in the storefront navigation (0 by default). Requires one of the following permissions: MANAGE_PAGES, MANAGE_PAGE_TYPES_AND_ATTRIBUTES, MANAGE_PRODUCTS, MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES."""- storefrontSearchPosition: Int! @deprecated+ storefrontSearchPosition: Int! @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Returns translated attribute fields for the given language code."""translation(@@ -10437,9 +10437,6 @@ input AttributeFilterInput @doc(category: "Attributes") {valueRequired: BooleanisVariantOnly: BooleanvisibleInStorefront: Boolean- filterableInStorefront: Boolean- filterableInDashboard: Boolean- availableInGrid: Booleanmetadata: [MetadataFilter!]search: Stringids: [ID!]@@ -10448,6 +10445,15 @@ input AttributeFilterInput @doc(category: "Attributes") {inCategory: IDslugs: [String!]+ """Whether the attribute can be filtered in storefront."""+ filterableInStorefront: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")++ """Whether the attribute can be displayed in the admin product list."""+ availableInGrid: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")++ """Whether the attribute can be filtered in dashboard."""+ filterableInDashboard: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the dashboard or use `Attribute` metadata instead.")+"""Specifies the channel by which the data should be filtered."""channel: String @deprecated(reason: "Use root-level channel argument instead.")}@@ -10473,7 +10479,9 @@ input AttributeWhereInput @doc(category: "Attributes") {inCategory: IDvalueRequired: BooleanvisibleInStorefront: Boolean- filterableInDashboard: Boolean++ """Whether the attribute can be filtered in dashboard."""+ filterableInDashboard: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the dashboard or use `Attribute` metadata instead.")"""List of conditions that must be met."""AND: [AttributeWhereInput!]@@ -17334,18 +17342,18 @@ enum AttributeSortField @doc(category: "Attributes") {VISIBLE_IN_STOREFRONT"""Sort attributes by the filterable in storefront flag"""- FILTERABLE_IN_STOREFRONT+ FILTERABLE_IN_STOREFRONT @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Sort attributes by the filterable in dashboard flag"""- FILTERABLE_IN_DASHBOARD+ FILTERABLE_IN_DASHBOARD @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the dashboard or use `Attribute` metadata instead.")"""Sort attributes by their position in storefront"""- STOREFRONT_SEARCH_POSITION+ STOREFRONT_SEARCH_POSITION @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Sort attributes based on whether they can be displayed or not in a product grid."""- AVAILABLE_IN_GRID+ AVAILABLE_IN_GRID @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")}"""Represents ongoing installation of app."""@@ -31965,18 +31973,18 @@ input AttributeCreateInput @doc(category: "Attributes") {visibleInStorefront: Boolean"""Whether the attribute can be filtered in storefront."""- filterableInStorefront: Boolean @deprecated+ filterableInStorefront: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Whether the attribute can be filtered in dashboard."""- filterableInDashboard: Boolean+ filterableInDashboard: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the dashboard or use `Attribute` metadata instead.")"""The position of the attribute in the storefront navigation (0 by default)."""- storefrontSearchPosition: Int @deprecated+ storefrontSearchPosition: Int @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Whether the attribute can be displayed in the admin product list."""- availableInGrid: Boolean @deprecated+ availableInGrid: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""External ID of this attribute."""externalReference: String@@ -32082,18 +32090,18 @@ input AttributeUpdateInput @doc(category: "Attributes") {visibleInStorefront: Boolean"""Whether the attribute can be filtered in storefront."""- filterableInStorefront: Boolean @deprecated+ filterableInStorefront: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Whether the attribute can be filtered in dashboard."""- filterableInDashboard: Boolean+ filterableInDashboard: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the dashboard or use `Attribute` metadata instead.")"""The position of the attribute in the storefront navigation (0 by default)."""- storefrontSearchPosition: Int @deprecated+ storefrontSearchPosition: Int @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""Whether the attribute can be displayed in the admin product list."""- availableInGrid: Boolean @deprecated+ availableInGrid: Boolean @deprecated(reason: "This flag is not used by Saleor. Keep the logic in the storefront or use `Attribute` metadata instead.")"""External ID of this product."""externalReference: String