Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add Shop.version field
Marcin Gębalac340d2a35682
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 86441c1194..a27957d88f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -83,6 +83,7 @@ All notable, unreleased changes to this project will be documented in this file.- Change the `app` query to return info about the currently authenticated app - #6928 by @d-wysocki- Add default sorting by rank for search products - #6936 by @d-wysocki- Fix exporting product description to xlsx - #6959 by @IKarbowiak+- Add `Shop.version` field to query API version - #6980 by @maarcingebala# 2.11.1diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 5d0c1ce915..264b576301 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -5049,6 +5049,7 @@ type Shop {companyAddress: AddresscustomerSetPasswordUrl: StringstaffNotificationRecipients: [StaffNotificationRecipient]+ version: String!}type ShopAddressUpdate {diff --git a/saleor/graphql/shop/tests/test_shop.py b/saleor/graphql/shop/tests/test_shop.pyindex 8323196514..1204fae560 100644--- a/saleor/graphql/shop/tests/test_shop.py+++ b/saleor/graphql/shop/tests/test_shop.py@@ -4,6 +4,7 @@ import grapheneimport pytestfrom django_countries import countries+from .... import __version__from ....account.models import Addressfrom ....core.error_codes import ShopErrorCodefrom ....core.permissions import get_permissions_codename@@ -1265,3 +1266,34 @@ def test_order_settings_query_as_staff(def test_order_settings_query_as_user(user_api_client, site_settings):response = user_api_client.post_graphql(ORDER_SETTINGS_QUERY)assert_no_permission(response)+++API_VERSION_QUERY = """+ query {+ shop {+ version+ }+ }+"""+++def test_version_query_as_anonymous_user(api_client):+ response = api_client.post_graphql(API_VERSION_QUERY)+ assert_no_permission(response)+++def test_version_query_as_customer(user_api_client):+ response = user_api_client.post_graphql(API_VERSION_QUERY)+ assert_no_permission(response)+++def test_version_query_as_app(app_api_client):+ response = app_api_client.post_graphql(API_VERSION_QUERY)+ content = get_graphql_content(response)+ assert content["data"]["shop"]["version"] == __version__+++def test_version_query_as_staff_user(staff_api_client):+ response = staff_api_client.post_graphql(API_VERSION_QUERY)+ content = get_graphql_content(response)+ assert content["data"]["shop"]["version"] == __version__diff --git a/saleor/graphql/shop/types.py b/saleor/graphql/shop/types.pyindex 158cda9b40..0622b71aa8 100644--- a/saleor/graphql/shop/types.py+++ b/saleor/graphql/shop/types.py@@ -7,6 +7,7 @@ from django_countries import countriesfrom django_prices_vatlayer.models import VATfrom phonenumbers import COUNTRY_CODE_TO_REGION_CODE+from ... import __version__from ...account import models as account_modelsfrom ...core.permissions import SitePermissions, get_permissionsfrom ...plugins.manager import get_plugins_manager@@ -18,7 +19,7 @@ from ..core.connection import CountableDjangoObjectTypefrom ..core.enums import WeightUnitsEnumfrom ..core.types.common import CountryDisplay, LanguageDisplay, Permissionfrom ..core.utils import str_to_enum-from ..decorators import permission_required+from ..decorators import permission_required, staff_member_or_app_requiredfrom ..menu.dataloaders import MenuByIdLoaderfrom ..menu.types import Menufrom ..shipping.types import ShippingMethod@@ -170,6 +171,7 @@ class Shop(graphene.ObjectType):description="List of staff notification recipients.",required=False,)+ version = graphene.String(description="Saleor API version.", required=True)class Meta:description = (@@ -333,3 +335,8 @@ class Shop(graphene.ObjectType):@permission_required(SitePermissions.MANAGE_SETTINGS)def resolve_staff_notification_recipients(_, info):return account_models.StaffNotificationRecipient.objects.all()++ @staticmethod+ @staff_member_or_app_required+ def resolve_version(_, _info):+ return __version__