Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add translation query for page
fowczarek7874d92e9e27
diff --git a/saleor/graphql/translations/schema.py b/saleor/graphql/translations/schema.pyindex 051ae7eec9..ce01528933 100644--- a/saleor/graphql/translations/schema.py+++ b/saleor/graphql/translations/schema.py@@ -1,5 +1,6 @@import graphene+from ...page.models import Pagefrom ...product.models import (Attribute,AttributeValue,@@ -47,7 +48,7 @@ class TranslatableItem(graphene.Union):)-# TODO Consider name of this class+# TODO Consider name of this class, maby we should replace TranslatableItemclass DefaultTranslationItem(graphene.Union):class Meta:types = (@@ -57,6 +58,7 @@ class DefaultTranslationItem(graphene.Union):translation_types.AttributeStrings,translation_types.AttributeValueStrings,translation_types.ProductVariantStrings,+ translation_types.PageStrings,)@@ -144,3 +146,6 @@ class TranslationQueries(graphene.ObjectType):elif kind == TranslatableKinds.VARIANT: # TODO test hidden data_type, product_variant_id = graphene.Node.from_global_id(id)return ProductVariant.objects.filter(pk=product_variant_id).first()+ elif kind == TranslatableKinds.PAGE: # TODO test hidden data+ _type, page_id = graphene.Node.from_global_id(id)+ return Page.objects.filter(pk=page_id).first()diff --git a/saleor/graphql/translations/types.py b/saleor/graphql/translations/types.pyindex b57b5b0e5c..09722c6f9a 100644--- a/saleor/graphql/translations/types.py+++ b/saleor/graphql/translations/types.py@@ -308,6 +308,45 @@ class PageTranslation(BaseTranslationType):]+class PageStrings(CountableDjangoObjectType):+ translation = graphene.Field(+ PageTranslation,+ language_code=graphene.Argument(+ LanguageCodeEnum,+ description="A language code to return the translation for.",+ required=True,+ ),+ description="Returns translated Page fields for the given language code.",+ resolver=resolve_translation,+ )+ page = graphene.Field(+ "saleor.graphql.page.types.Page",+ description=(+ "A static page that can be manually added by a shop operator ",+ "through the dashboard.",+ ),+ )++ class Meta:+ model = page_models.Page+ interfaces = [graphene.relay.Node]+ only_fields = [+ "content",+ "content_json",+ "id",+ "seo_description",+ "seo_title",+ "title",+ ]++ def resolve_page(self, info):+ return (+ page_models.Page.objects.visible_to_user(info.context.user)+ .filter(pk=self.id)+ .first()+ )++class VoucherTranslation(BaseTranslationType):class Meta:model = discount_models.VoucherTranslation