Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Update sorting field desciptions - add info where channel slug is required (#9695)
Iga Karbowiak3917430980c3
diff --git a/saleor/graphql/core/descriptions.py b/saleor/graphql/core/descriptions.pyindex 8d5d6bd28e..0ac130c909 100644--- a/saleor/graphql/core/descriptions.py+++ b/saleor/graphql/core/descriptions.py@@ -21,3 +21,8 @@ PREVIEW_FEATURE = ("\n\nNote: this API is currently in Feature Preview and can be subject to ""changes at later point.")++CHANNEL_REQUIRED = (+ "\n\nThis option requires a channel filter to work as the values can vary "+ "between channels."+)diff --git a/saleor/graphql/discount/sorters.py b/saleor/graphql/discount/sorters.pyindex 6fb7a02db1..600c6a955b 100644--- a/saleor/graphql/discount/sorters.py+++ b/saleor/graphql/discount/sorters.py@@ -1,6 +1,7 @@import graphenefrom django.db.models import Min, Q, QuerySet+from ..core.descriptions import CHANNEL_REQUIREDfrom ..core.types import ChannelSortInputObjectType@@ -15,9 +16,13 @@ class SaleSortField(graphene.Enum):@propertydef description(self):+ descrption_extras = {SaleSortField.VALUE.name: [CHANNEL_REQUIRED]}if self.name in SaleSortField.__enum__._member_names_:sort_name = self.name.lower().replace("_", " ")- return f"Sort sales by {sort_name}."+ description = f"Sort sales by {sort_name}."+ if extras := descrption_extras.get(self.name):+ description += "".join(extras)+ return descriptionraise ValueError("Unsupported enum value: %s" % self.value)@staticmethod@@ -47,9 +52,16 @@ class VoucherSortField(graphene.Enum):@propertydef description(self):+ descrption_extras = {+ VoucherSortField.VALUE.name: [CHANNEL_REQUIRED],+ VoucherSortField.MINIMUM_SPENT_AMOUNT.name: [CHANNEL_REQUIRED],+ }if self.name in VoucherSortField.__enum__._member_names_:sort_name = self.name.lower().replace("_", " ")- return f"Sort vouchers by {sort_name}."+ description = f"Sort vouchers by {sort_name}."+ if extras := descrption_extras.get(self.name):+ description += "".join(extras)+ return descriptionraise ValueError("Unsupported enum value: %s" % self.value)@staticmethoddiff --git a/saleor/graphql/product/sorters.py b/saleor/graphql/product/sorters.pyindex a0d58094cc..2e2aae0968 100644--- a/saleor/graphql/product/sorters.py+++ b/saleor/graphql/product/sorters.py@@ -21,7 +21,7 @@ from ...product.models import (Product,ProductChannelListing,)-from ..core.descriptions import DEPRECATED_IN_3X_INPUT+from ..core.descriptions import CHANNEL_REQUIRED, DEPRECATED_IN_3X_INPUTfrom ..core.types import ChannelSortInputObjectType, SortInputObjectType@@ -78,11 +78,19 @@ class CollectionSortField(graphene.Enum):@propertydef description(self):+ descrption_extras = {+ CollectionSortField.AVAILABILITY.name: [CHANNEL_REQUIRED],+ CollectionSortField.PUBLICATION_DATE.name: [+ CHANNEL_REQUIRED,+ DEPRECATED_IN_3X_INPUT,+ ],+ CollectionSortField.PUBLISHED_AT.name: [CHANNEL_REQUIRED],+ }if self.name in CollectionSortField.__enum__._member_names_:sort_name = self.name.lower().replace("_", " ")description = f"Sort collections by {sort_name}."- if self.name == "PUBLICATION_DATE":- description += DEPRECATED_IN_3X_INPUT+ if extras := descrption_extras.get(self.name):+ description += "".join(extras)return descriptionraise ValueError("Unsupported enum value: %s" % self.value)@@ -145,25 +153,30 @@ class ProductOrderField(graphene.Enum):ProductOrderField.COLLECTION.name: ("collection. Note: ""This option is available only for the `Collection.products` query."+ + CHANNEL_REQUIRED),ProductOrderField.RANK.name: ("rank. Note: This option is available only with the `search` filter."),ProductOrderField.NAME.name: "name.",- ProductOrderField.PRICE.name: "price.",+ ProductOrderField.PRICE.name: ("price." + CHANNEL_REQUIRED),ProductOrderField.TYPE.name: "type.",ProductOrderField.MINIMAL_PRICE.name: (- "a minimal price of a product's variant."+ "a minimal price of a product's variant." + CHANNEL_REQUIRED),ProductOrderField.DATE.name: f"update date. {DEPRECATED_IN_3X_INPUT}",- ProductOrderField.PUBLISHED.name: "publication status.",+ ProductOrderField.PUBLISHED.name: (+ "publication status." + CHANNEL_REQUIRED+ ),ProductOrderField.PUBLICATION_DATE.name: (- f"publication date. {DEPRECATED_IN_3X_INPUT}"+ "publication date." + CHANNEL_REQUIRED + DEPRECATED_IN_3X_INPUT),ProductOrderField.LAST_MODIFIED.name: (f"update date. {DEPRECATED_IN_3X_INPUT}"),- ProductOrderField.PUBLISHED_AT.name: "publication date.",+ ProductOrderField.PUBLISHED_AT.name: (+ "publication date." + CHANNEL_REQUIRED+ ),ProductOrderField.LAST_MODIFIED_AT.name: "update date.",ProductOrderField.RATING.name: "rating.",}diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex d4233709d0..18435b56f5 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -5410,10 +5410,18 @@ enum ProductOrderField {"""RANK- """Sort products by price."""+ """+ Sort products by price.++ This option requires a channel filter to work as the values can vary between channels.+ """PRICE- """Sort products by a minimal price of a product's variant."""+ """+ Sort products by a minimal price of a product's variant.++ This option requires a channel filter to work as the values can vary between channels.+ """MINIMAL_PRICE"""Sort products by update date."""@@ -5425,13 +5433,25 @@ enum ProductOrderField {"""Sort products by type."""TYPE- """Sort products by publication status."""+ """+ Sort products by publication status.++ This option requires a channel filter to work as the values can vary between channels.+ """PUBLISHED- """Sort products by publication date."""+ """+ Sort products by publication date.++ This option requires a channel filter to work as the values can vary between channels.+ """PUBLICATION_DATE- """Sort products by publication date."""+ """+ Sort products by publication date.++ This option requires a channel filter to work as the values can vary between channels.+ """PUBLISHED_AT"""Sort products by update date."""@@ -5439,6 +5459,8 @@ enum ProductOrderField {"""Sort products by collection. Note: This option is available only for the `Collection.products` query.++ This option requires a channel filter to work as the values can vary between channels."""COLLECTION@@ -8828,7 +8850,11 @@ enum CollectionSortField {"""Sort collections by name."""NAME- """Sort collections by availability."""+ """+ Sort collections by availability.++ This option requires a channel filter to work as the values can vary between channels.+ """AVAILABILITY"""Sort collections by product count."""@@ -8837,14 +8863,14 @@ enum CollectionSortField {"""Sort collections by publication date.- DEPRECATED: this field will be removed in Saleor 4.0.+ This option requires a channel filter to work as the values can vary between channels."""PUBLICATION_DATE"""Sort collections by publication date.- DEPRECATED: this field will be removed in Saleor 4.0.+ This option requires a channel filter to work as the values can vary between channels."""PUBLISHED_AT}@@ -9405,7 +9431,11 @@ enum SaleSortField {"""Sort sales by end date."""END_DATE- """Sort sales by value."""+ """+ Sort sales by value.++ This option requires a channel filter to work as the values can vary between channels.+ """VALUE"""Sort sales by type."""@@ -9475,7 +9505,11 @@ enum VoucherSortField {"""Sort vouchers by end date."""END_DATE- """Sort vouchers by value."""+ """+ Sort vouchers by value.++ This option requires a channel filter to work as the values can vary between channels.+ """VALUE"""Sort vouchers by type."""@@ -9484,7 +9518,11 @@ enum VoucherSortField {"""Sort vouchers by usage limit."""USAGE_LIMIT- """Sort vouchers by minimum spent amount."""+ """+ Sort vouchers by minimum spent amount.++ This option requires a channel filter to work as the values can vary between channels.+ """MINIMUM_SPENT_AMOUNT}