From 3f5d4fe85463228cac4316748faf2572030ba4d5 Mon Sep 17 00:00:00 2001 From: Philipp Melab Date: Sat, 27 Jul 2024 09:24:52 +0200 Subject: [PATCH] refactor: simplify menus --- packages/schema/src/schema.graphql | 28 +++++++--------------------- tests/schema/specs/menu.spec.ts | 2 +- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/packages/schema/src/schema.graphql b/packages/schema/src/schema.graphql index 6c87f0dc5..cd52d4264 100644 --- a/packages/schema/src/schema.graphql +++ b/packages/schema/src/schema.graphql @@ -118,24 +118,11 @@ type NavigationItem { target: Url! @resolveMenuItemUrl } -interface Navigation { - locale: Locale! - items: [NavigationItem]! -} - -type MetaNavigation implements Navigation @menu(menu_id: "meta") { - locale: Locale! @resolveEntityLanguage - items: [NavigationItem]! @lang @resolveMenuItems(max_level: 1) -} - -type MainNavigation implements Navigation @menu(menu_id: "main") { +type Navigation { locale: Locale! @resolveEntityLanguage - items: [NavigationItem]! @lang @resolveMenuItems -} - -type FooterNavigation implements Navigation @menu(menu_id: "footer") { - locale: Locale! @resolveEntityLanguage - items: [NavigationItem]! @lang @resolveMenuItems + items(max_level: Int): [NavigationItem]! + @lang + @resolveMenuItems(max_level: "$max_level") } interface Page implements ContentHubResultItem @resolveEntityBundle { @@ -345,10 +332,9 @@ type Query { previewDrupalPage(id: ID!, rid: ID, locale: String!): DrupalPage @fetchEntity(type: "node", id: "$id", rid: "$rid", language: "$locale") - mainNavigations: [MainNavigation] @menuTranslations(menu_id: "main") - metaNavigations: [MetaNavigation] @menuTranslations(menu_id: "meta") - - footerNavigations: [FooterNavigation] @menuTranslations(menu_id: "footer") + mainNavigations: [Navigation] @menuTranslations(menu_id: "main") + metaNavigations: [Navigation] @menuTranslations(menu_id: "meta") + footerNavigations: [Navigation] @menuTranslations(menu_id: "footer") ssgPages(args: String): SSGPagesResult @drupalView(id: "ssg_pages:default", args: "$args") diff --git a/tests/schema/specs/menu.spec.ts b/tests/schema/specs/menu.spec.ts index 54e7757f0..7c761c4a0 100644 --- a/tests/schema/specs/menu.spec.ts +++ b/tests/schema/specs/menu.spec.ts @@ -6,7 +6,7 @@ import { fetch } from '../lib.js'; test('Meta', async () => { const result = await fetch(gql` { - metaNavigations { + metaNavigations(max_level: 1) { locale items { title