Menu
Represents a navigational menu containing a list of links, typically used for site navigation structures such as main menus or footers.
Type Definition
type Menu {
handle: String
levels: Int
links: [Link]
title: String
}
Fields
Field | Type | Nullable | Description | Related Type |
---|---|---|---|---|
handle | String | Yes | Unique identifier (token) for this menu, used to reference the menu programmatically. | - |
levels | Int | Yes | The total number of nested levels in this menu, representing the depth of the menu hierarchy. | - |
links | [Link] | Yes | The list of top-level links in this menu. Each link may have its own child links, forming a hierarchical structure. | Link |
title | String | Yes | The display name of the menu, typically shown as the menu’s title in navigation components. | - |
Relationships
- links: This field contains an array of
Link
objects representing the top-level links in the menu. EachLink
may have nested child links, enabling hierarchical navigation structures. - The
handle
field serves as a programmatic identifier to retrieve or reference a specificMenu
.
Usage Examples
Basic Query
query {
menu(handle: "main-menu") {
handle
title
levels
}
}
Field Selection
query {
menu(handle: "footer-menu") {
title
links {
title
url
}
}
}
Nested Queries
query {
menu(handle: "main-menu") {
title
links {
title
url
childLinks {
title
url
}
}
}
}
Filtering and Sorting
The Menu
type itself does not support filtering or sorting fields directly. Filtering is typically done by specifying the handle
argument in the menu
query to retrieve a specific menu.
Example filtering by handle:
query {
menu(handle: "main-menu") {
title
levels
links {
title
url
}
}
}
Implements
The Menu
type does not implement any GraphQL interfaces.
Connections
The Menu
type has a connection to the Link
type via the links
field, which is a list of Link
objects representing the menu’s navigational entries.
Related Types
- Link: Represents an individual navigational link within a menu. Links can be nested to form hierarchical structures.
Best Practices
- Use the
handle
field to query specific menus efficiently. - When querying menus with many nested links, limit the depth of nested queries to avoid performance issues.
- Cache menu queries where possible, as menus typically change infrequently.
- Use the
levels
field to understand the depth of the menu hierarchy and optimize UI rendering accordingly.
Notes
- The
links
field may be null or empty if the menu has no links. - The API currently requires no authentication, but this may change in future versions.
- Be mindful of query complexity when requesting deeply nested links to avoid performance degradation.
- The
levels
field is a computed value representing the maximum depth of nested links in the menu. - No field arguments are defined on the
Menu
type fields themselves; filtering is done via the query argumenthandle
.
Last updated on