Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add `schemaVersion` field to `Shop` type (#11275)
Piotr Zabieglik26a44b718c59
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7626990007..87738cb7b8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -239,6 +239,7 @@ All notable, unreleased changes to this project will be documented in this file.- Expose manifest in the `App` type (#10055) (f0f944066)- Deprecate `configurationUrl` and `dataPrivacy` fields in apps (#10046) (68bd7c8a2)- Fix `ProductVariant.created` resolver (#10072) (6c77053a9)+- Add `schemaVersion` field to `Shop` type. #11275 by @zedzior### Saleor Appsdiff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 58b5312825..e61be71717 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -8240,6 +8240,13 @@ type Shop {"""version: String!+ """+ Minor Saleor API version.++ Added in Saleor 3.5.+ """+ schemaVersion: String!+"""Include taxes in prices."""includeTaxesInPrices: Boolean! @deprecated(reason: "This field will be removed in Saleor 4.0. Use `Channel.taxConfiguration.pricesEnteredWithTax` to determine whether prices are entered with tax.")diff --git a/saleor/graphql/shop/tests/test_shop.py b/saleor/graphql/shop/tests/test_shop.pyindex 5efcad2ea7..f9eb463434 100644--- a/saleor/graphql/shop/tests/test_shop.py+++ b/saleor/graphql/shop/tests/test_shop.py@@ -1,3 +1,4 @@+import refrom unittest.mock import ANYimport graphene@@ -1559,6 +1560,27 @@ def test_version_query_as_staff_user(staff_api_client):assert content["data"]["shop"]["version"] == __version__+def test_schema_version_query(api_client):+ # given+ query = """+ query {+ shop {+ schemaVersion+ }+ }+ """+ m = re.match(r"^(\d+)\.(\d+)\.\d+", __version__)+ assert m is not None+ major, minor = m.groups()++ # when+ response = api_client.post_graphql(query)+ content = get_graphql_content(response)++ # then+ assert content["data"]["shop"]["schemaVersion"] == f"{major}.{minor}"++def test_cannot_get_shop_limit_info_when_not_staff(user_api_client):query = LIMIT_INFO_QUERYresponse = user_api_client.post_graphql(query)diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.pyindex bd1988c21f..f0433e843c 100644--- a/saleor/graphql/shop/types.py+++ b/saleor/graphql/shop/types.py@@ -17,6 +17,7 @@ from ..account.types import Address, AddressInput, StaffNotificationRecipientfrom ..checkout.types import PaymentGatewayfrom ..core.descriptions import (ADDED_IN_31,+ ADDED_IN_35,DEPRECATED_IN_3X_FIELD,DEPRECATED_IN_3X_INPUT,PREVIEW_FEATURE,@@ -293,6 +294,10 @@ class Shop(graphene.ObjectType):AuthorizationFilters.AUTHENTICATED_APP,],)+ schema_version = graphene.String(+ description="Minor Saleor API version." + ADDED_IN_35,+ required=True,+ )# deprecatedinclude_taxes_in_prices = graphene.Boolean(@@ -506,6 +511,11 @@ class Shop(graphene.ObjectType):def resolve_version(_, _info):return __version__+ @staticmethod+ def resolve_schema_version(_, _info):+ major, minor, _ = __version__.split(".", 2)+ return f"{major}.{minor}"+# deprecated@staticmethod