Menu
Schema
Base
graphql
type MenuLinkTreeElement {
link: MenuLink!
subtree: [MenuLinkTreeElement!]!
}
type MenuLink {
url: Url
label: String!
description: String
expanded: Boolean!
content: MenuLinkContent
attribute(name: String!): String
}
Extension
graphql
extend type Menu {
links(root: String = null, activeTrailIds: [String] = null, minDepth: Int = null, maxDepth: Int = null): [MenuLinkTreeElement!]!
}
extend type Query {
"""
Load a menu by its name. The menu is loaded automatically in the
current language.
"""
menuByName(
"""
The name of the menu.
"""
name: MenuName!
): Menu
}
Enum
The MenuName
enum is generated based on the menus that exist in Drupal, e.g.:
graphql
enum MenuName {
ADMIN
FOOTER
MAIN
TOOLS
}
Example
graphql
query mainMenu {
menuByName(name: ADMIN) {
links {
...mainMenuLinkTree
subtree {
...mainMenuLinkTree
}
}
}
}
fragment mainMenuLinkTree on MenuLinkTreeElement {
link {
label
url {
path
}
}
}
json
{
"data": {
"menuByName": {
"links": [
{
"link": {
"label": "Verwaltung",
"url": {
"path": "/de/admin"
}
},
"subtree": [
{
"link": {
"label": "Werkzeuge",
"url": {
"path": "/de"
}
}
},
{
"link": {
"label": "Inhalt",
"url": {
"path": "/de/admin/content"
}
}
},
{
"link": {
"label": "Struktur",
"url": {
"path": "/de/admin/structure"
}
}
},
{
"link": {
"label": "Design",
"url": {
"path": "/de/admin/appearance"
}
}
},
{
"link": {
"label": "Erweitern",
"url": {
"path": "/de/admin/modules"
}
}
},
{
"link": {
"label": "Konfiguration",
"url": {
"path": "/de/admin/config"
}
}
},
{
"link": {
"label": "Benutzer",
"url": {
"path": "/de/admin/people"
}
}
},
{
"link": {
"label": "Berichte",
"url": {
"path": "/de/admin/reports"
}
}
},
{
"link": {
"label": "Help",
"url": {
"path": "/de/admin/help"
}
}
}
]
}
]
}
}
}