Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add translation query for attribute value
fowczarekab3022ebb1a4
diff --git a/saleor/graphql/translations/schema.py b/saleor/graphql/translations/schema.pyindex 713d7912c1..b121027791 100644--- a/saleor/graphql/translations/schema.py+++ b/saleor/graphql/translations/schema.py@@ -1,6 +1,6 @@import graphene-from ...product.models import Attribute, Category, Collection, Product+from ...product.models import Attribute, AttributeValue, Category, Collection, Productfrom ..core.connection import CountableConnectionfrom ..core.fields import BaseConnectionFieldfrom ..decorators import permission_required@@ -48,6 +48,7 @@ class DefaultTranslationItem(graphene.Union):translation_types.CollectionStrings,translation_types.CategoryStrings,translation_types.AttributeStrings,+ translation_types.AttributeValueStrings,)@@ -129,3 +130,6 @@ class TranslationQueries(graphene.ObjectType):elif kind == TranslatableKinds.ATTRIBUTE:_type, attribute_id = graphene.Node.from_global_id(id)return Attribute.objects.filter(pk=attribute_id).first()+ elif kind == TranslatableKinds.ATTRIBUTE_VALUE:+ _type, attribute_value_id = graphene.Node.from_global_id(id)+ return AttributeValue.objects.filter(pk=attribute_value_id).first()diff --git a/saleor/graphql/translations/types.py b/saleor/graphql/translations/types.pyindex 247a0ad8e6..0b2d15e140 100644--- a/saleor/graphql/translations/types.py+++ b/saleor/graphql/translations/types.py@@ -44,6 +44,33 @@ class AttributeValueTranslation(BaseTranslationType):only_fields = ["id", "name"]+class AttributeValueStrings(CountableDjangoObjectType):+ translation = graphene.Field(+ AttributeValueTranslation,+ language_code=graphene.Argument(+ LanguageCodeEnum,+ description="A language code to return the translation for.",+ required=True,+ ),+ description=(+ "Returns translated Attribute Value fields " "for the given language code."+ ),+ resolver=resolve_translation,+ )+ attribute_value = graphene.Field(+ "saleor.graphql.product.types.attributes.AttributeValue",+ description="Represents a value of an attribute.",+ )++ class Meta:+ model = product_models.AttributeValue+ interfaces = [graphene.relay.Node]+ only_fields = ["id", "name"]++ def resolve_attribute_value(self, info):+ return self++class AttributeTranslation(BaseTranslationType):class Meta:model = product_models.AttributeTranslation@@ -65,7 +92,7 @@ class AttributeStrings(CountableDjangoObjectType):resolver=resolve_translation,)attribute = graphene.Field(- "saleor.graphql.product.types.products.Attribute",+ "saleor.graphql.product.types.attributes.Attribute",description="Custom attribute of a product.",)