Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Return CountryDisplay instead of AddressCountry

Pacu2859d10a3374d
diff --git a/saleor/graphql/account/types.py b/saleor/graphql/account/types.py
index ed5c75ed39..b0bd97b4b4 100644
--- a/saleor/graphql/account/types.py
+++ b/saleor/graphql/account/types.py
@@ -4,7 +4,8 @@ from graphene import relay
from ...account import models
from ...core.permissions import get_permissions
-from ..core.types.common import CountableDjangoObjectType, PermissionDisplay
+from ..core.types.common import (
+ CountableDjangoObjectType, CountryDisplay, PermissionDisplay)
from ..utils import format_permissions_for_display
@@ -23,12 +24,21 @@ class AddressInput(graphene.InputObjectType):
class Address(CountableDjangoObjectType):
+ country = graphene.Field(
+ CountryDisplay, description='Default shop\'s country')
+
class Meta:
exclude_fields = ['user_set', 'user_addresses']
description = 'Represents user address data.'
interfaces = [relay.Node]
model = models.Address
+ def resolve_country(self, info):
+ if self.country:
+ return CountryDisplay(
+ code=self.country.code, country=self.country.name)
+ return None
+
class User(CountableDjangoObjectType):
permissions = graphene.List(PermissionDisplay)