Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Handle external shipping methods in translations resolver (#8971)
Rafał Pitoń39a4c12d3dd1
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 38fd3932c5..e15e90d7ea 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,6 +27,7 @@ All notable, unreleased changes to this project will be documented in this file.- in create mutations: require all required attributes- in update mutations: do not require providing any attributes; when any attribute is given, validate provided values.- Do no allow using id for updating checkout and order metadata - #8906 by @IKarbowiak+- Fix crash when querying external shipping method's `translation` field - #8971 by @rafalp# 3.0.0 [Unreleased]diff --git a/saleor/graphql/checkout/tests/test_checkout.py b/saleor/graphql/checkout/tests/test_checkout.pyindex 5af421e308..4e44e89366 100644--- a/saleor/graphql/checkout/tests/test_checkout.py+++ b/saleor/graphql/checkout/tests/test_checkout.py@@ -1758,11 +1758,13 @@ def test_checkout_available_shipping_methods_excluded_postal_codes(assert data["availableShippingMethods"] == [][email protected]("saleor.plugins.webhook.tasks.send_webhook_request_sync")@pytest.mark.parametrize("expected_price_type, expected_price, display_gross_prices",(("gross", 13, True), ("net", 10, False)),)def test_checkout_available_shipping_methods_with_price_displayed(+ send_webhook_request_sync,expected_price_type,expected_price,display_gross_prices,@@ -1772,6 +1774,7 @@ def test_checkout_available_shipping_methods_with_price_displayed(address,shipping_zone,site_settings,+ shipping_app,):shipping_method = shipping_zone.shipping_methods.first()shipping_price = shipping_method.channel_listings.get(@@ -3190,6 +3193,9 @@ MUTATION_UPDATE_DELIVERY_METHOD = """... on ShippingMethod {nameid+ translation(languageCode: EN_US) {+ name+ }}... on Warehouse {namediff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.pyindex 33f53f9dc7..1d9f89a733 100644--- a/saleor/graphql/shipping/types.py+++ b/saleor/graphql/shipping/types.py@@ -86,7 +86,7 @@ class ShippingMethod(ChannelContextTypeWithMetadataForObjectType):translation = TranslationField(ShippingMethodTranslation,type_name="shipping method",- resolver=ChannelContextType.resolve_translation,+ resolver=None, # Disable default resolver)channel_listings = graphene.List(graphene.NonNull(ShippingMethodChannelListing),@@ -139,6 +139,17 @@ class ShippingMethod(ChannelContextTypeWithMetadataForObjectType):return root.node.idreturn graphene.Node.to_global_id("ShippingMethod", root.node.id)+ @staticmethod+ def resolve_translation(+ root: ChannelContext[Union[ShippingMethodData, models.ShippingMethod]],+ info,+ language_code,+ ):+ if getattr(root.node, "is_external", False):+ return None++ return ChannelContextType.resolve_translation(root, info, language_code)+@staticmethoddef resolve_price(root: ChannelContext[Union[ShippingMethodData, models.ShippingMethod]],