Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add translation query for menu item
fowczarek66d9755cdfd4
diff --git a/saleor/graphql/translations/schema.py b/saleor/graphql/translations/schema.pyindex d8d5208fe2..5581845462 100644--- a/saleor/graphql/translations/schema.py+++ b/saleor/graphql/translations/schema.py@@ -1,6 +1,7 @@import graphenefrom ...discount.models import Sale, Voucher+from ...menu.models import MenuItemfrom ...page.models import Pagefrom ...product.models import (Attribute,@@ -64,6 +65,7 @@ class DefaultTranslationItem(graphene.Union):translation_types.ShippingMethodStrings,translation_types.SaleStrings,translation_types.VoucherStrings,+ translation_types.MenuItemStrings,)@@ -159,9 +161,15 @@ class TranslationQueries(graphene.ObjectType):elif kind == TranslatableKinds.SHIPPING_METHOD:_type, shipping_method_id = graphene.Node.from_global_id(id)return ShippingMethod.objects.filter(pk=shipping_method_id).first()+ # TODO test data not visible without permselif kind == TranslatableKinds.SALE:_type, sale_id = graphene.Node.from_global_id(id)return Sale.objects.filter(pk=sale_id).first()+ # TODO test data not visible without permselif kind == TranslatableKinds.VOUCHER:_type, voucher_id = graphene.Node.from_global_id(id)return Voucher.objects.filter(pk=voucher_id).first()+ # TODO No dashbord options to create translation create issue+ elif kind == TranslatableKinds.MENU_ITEM:+ _type, menu_item_id = graphene.Node.from_global_id(id)+ return MenuItem.objects.filter(pk=menu_item_id).first()diff --git a/saleor/graphql/translations/types.py b/saleor/graphql/translations/types.pyindex 2a1d2a09f1..5cfba564e7 100644--- a/saleor/graphql/translations/types.py+++ b/saleor/graphql/translations/types.py@@ -436,6 +436,36 @@ class MenuItemTranslation(BaseTranslationType):only_fields = ["id", "name"]+class MenuItemStrings(CountableDjangoObjectType):+ translation = graphene.Field(+ MenuItemTranslation,+ language_code=graphene.Argument(+ LanguageCodeEnum,+ description="A language code to return the translation for.",+ required=True,+ ),+ description=(+ "Returns translated Menu item fields " "for the given language code."+ ),+ resolver=resolve_translation,+ )+ menu_item = graphene.Field(+ "saleor.graphql.menu.types.MenuItem",+ description=(+ "Represents a single item of the related menu. Can store categories, "+ "collection or pages."+ ),+ )++ class Meta:+ model = menu_models.MenuItem+ interfaces = [graphene.relay.Node]+ only_fields = ["id", "name"]++ def resolve_menu_item(self, info):+ return self++class ShippingMethodTranslation(BaseTranslationType):class Meta:model = shipping_models.ShippingMethodTranslation