Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change MenuItem.children to List
oldPadavan6b861e125576
diff --git a/saleor/graphql/menu/types.py b/saleor/graphql/menu/types.pyindex feccae6cd4..9950b1fb5a 100644--- a/saleor/graphql/menu/types.py+++ b/saleor/graphql/menu/types.py@@ -7,6 +7,9 @@ from ..core.types.common import CountableDjangoObjectTypeclass MenuItem(CountableDjangoObjectType):url = graphene.String(description='URL to the menu item.')+ children = graphene.List(+ lambda: MenuItem, required=True,+ description='List of menu item children items')class Meta:description = """Represents a single item of the related menu.@@ -16,6 +19,9 @@ class MenuItem(CountableDjangoObjectType):filter_fields = {}model = models.MenuItem+ def resolve_children(self, info, **kwargs):+ return self.children.all()+class Menu(CountableDjangoObjectType):items = graphene.List(diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphqlindex dfd9984c88..20664917c5 100644--- a/saleor/graphql/schema.graphql+++ b/saleor/graphql/schema.graphql@@ -576,7 +576,7 @@ type MenuItem implements Node {collection: Collectionpage: Pagelevel: Int!- children(before: String, after: String, first: Int, last: Int): MenuItemCountableConnection+ children: [MenuItem]!}type MenuItemCountableConnection {diff --git a/tests/api/test_menu.py b/tests/api/test_menu.pyindex f2d58110d1..8e133339ee 100644--- a/tests/api/test_menu.py+++ b/tests/api/test_menu.py@@ -2,6 +2,7 @@ import pytestimport graphenefrom saleor.graphql.menu.mutations import NavigationType+from saleor.menu.models import MenuItemfrom tests.api.utils import get_graphql_contentfrom .utils import assert_no_permission@@ -78,7 +79,7 @@ def test_menu_items_query(user_api_client, menu_item, collection):menuItem(id: $id) {namechildren {- totalCount+ name}collection {name@@ -96,12 +97,16 @@ def test_menu_items_query(user_api_client, menu_item, collection):menu_item.collection = collectionmenu_item.url = Nonemenu_item.save()+ child_menu = MenuItem.objects.create(+ menu=menu_item.menu, name='Link 2', url='http://example2.com/',+ parent=menu_item)variables = {'id': graphene.Node.to_global_id('MenuItem', menu_item.pk)}response = user_api_client.post_graphql(query, variables)content = get_graphql_content(response)data = content['data']['menuItem']assert data['name'] == menu_item.name- assert data['children']['totalCount'] == menu_item.children.count()+ assert len(data['children']) == 1+ assert data['children'][0]['name'] == child_menu.nameassert data['collection']['name'] == collection.nameassert not data['category']assert not data['page']