Repository navigation
10. GraphQL
Olive Menus 5.1 exposes a read-only query for headless Craft sites. It uses Craft's built-in GraphQL API, which is available in Craft Solo and the paid editions. The kind and isDynamic fields in this example require Olive Menus 5.2. The megaMenu object requires Olive Menus 5.3.
- In Craft, open GraphQL → Schemas and select or create the schema your frontend uses.
- Under Olive Menus, enable Read navigation menus. Under Sites, enable each site the schema should read.
- For groups filled from sections, enable read access to the source sections and the entry types you want in the menu. If Craft runs the query as a user, their entry edit permissions also apply to those generated links.
- In GraphiQL, select that schema, then run the example below. On an HTTP endpoint, use a token for a private schema or explicitly enable the query in the public schema.

query HeaderNavigation {
oliveMenu(handle: "mainMenu", site: "default") {
name
handle
site
items {
id
name
kind
isDynamic
url
target
linkClass
itemClass
megaMenu {
columns
description
}
attributes {
name
value
}
children {
id
name
kind
isDynamic
url
}
}
}
}Replace default with the target Craft site's handle. Omit site to use Craft's current site for the request.
The query returns null for a missing menu or a site the schema cannot read. When requested, items, children, and attributes return lists, including empty lists when there are no values. Ask for more nested children fields if your menu has deeper levels.
The kind field returns link for linked elements and custom links, heading for headings, group for groups, or site for site links. isDynamic is true for links generated from a group’s source section. Their id is a string, just like other GraphQL IDs.
Headings, groups, and other unlinked labels have a null URL. A Site link returns its destination site's base URL when available. For a linked element, url includes its saved URL suffix. Hidden items and their descendants are omitted. GraphQL evaluates audience rules as a guest and applies site and time rules. Visibility and mega menus
Render the returned data in your frontend. Determine the active item from the visitor's page URL, since the GraphQL request may run at a separate endpoint. Craft GraphQL documentation