Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Unify countries handling
Pacu2a592fd48bd9d
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex 222c79d19d..e3b9264e20 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -1664,7 +1664,7 @@ type ShippingPriceUpdate {type ShippingZone implements Node {id: ID!name: String!- countries: [String]+ countries: [CountryDisplay]default: Boolean!shippingMethods: [ShippingMethod]priceRange: MoneyRangediff --git a/saleor/graphql/shipping/types.py b/saleor/graphql/shipping/types.pyindex 7fab569827..0811398902 100644--- a/saleor/graphql/shipping/types.py+++ b/saleor/graphql/shipping/types.py@@ -8,7 +8,7 @@ from measurement.measures import Weightfrom ...core.weight import convert_weight, get_default_weight_unitfrom ...shipping import ShippingMethodType, models-from ..core.types.common import CountableDjangoObjectType+from ..core.types.common import CountableDjangoObjectType, CountryDisplayfrom ..core.types.money import MoneyRangeShippingMethodTypeEnum = graphene.Enum(@@ -33,7 +33,7 @@ class ShippingZone(CountableDjangoObjectType):price_range = graphene.Field(MoneyRange, description='Lowest and highest prices for the shipping.')countries = graphene.List(- graphene.String,+ CountryDisplay,description='List of countries available for the method.')shipping_methods = graphene.List(ShippingMethod,@@ -57,7 +57,9 @@ class ShippingZone(CountableDjangoObjectType):return self.price_rangedef resolve_countries(self, info):- return self.countries+ return [+ CountryDisplay(code=country.code, country=country.name)+ for country in self.countries]def resolve_shipping_methods(self, info):return self.shipping_methods.all()diff --git a/tests/api/test_shipping_method.py b/tests/api/test_shipping_method.pyindex dacc71b816..77300da4e5 100644--- a/tests/api/test_shipping_method.py+++ b/tests/api/test_shipping_method.py@@ -134,7 +134,9 @@ CREATE_SHIPPING_ZONE_QUERY = """}shippingZone {name- countries+ countries {+ code+ }default}}@@ -153,7 +155,7 @@ def test_create_shipping_zone(admin_api_client):assert not data['errors']zone = data['shippingZone']assert zone['name'] == 'test shipping'- assert zone['countries'] == ['PL']+ assert zone['countries'] == [{'code': 'PL'}]assert zone['default'] == False