I have a "Settings" document with a repeatable group called "Navigation." This group has one field called "Mega Menu Item." It's a content relationship that can link to Mega Menu Item documents, each of which has its own fields. Something like this:
settings: {
navigation: [
{
mega_menu_item: {
label
url
}
}
]
}
I want to get all items in settings.navigation, and also the fields of each item's linked document. I have tried writing the GraphQuery for this, but no matter what I try, I can't get the fields. I only get the array of items in "navigation," each of which contains a single "link_type: 'Document'" field.
Here is the query I came up with:
const response = await client.getSingle("settings", {
graphQuery: `
{
navigation {
mega_menu_item {
...on mega_menu_item {
label
url
}
}
}
}`,
});
Please let me know what I'm doing wrong here. My goal here is to understand Prismic's GraphQuery better so that I can more easily build my own queries.
NOTE: It may look as though I could have just put "label" and "url" directly in the repeatable group, instead of linking to another document. However, my actual use case is that I need each Mega Menu Item to itself contain multiple sections. For now, though, I'm just trying to solve this issue with fetching the top level, before getting deeper into the nesting.