Exposing menu link view mode

Created on 8 May 2025, 3 months ago

Problem/Motivation

In some use cases, especially when rendering menus in a headless Drupal setup, site builders and frontend applications need to know the view_mode associated with each menu link (for example, to determine how to render linked content or components differently in various menu contexts). Currently, the graphql schema does not expose this view_mode information on MenuItem objects.

Benefits

  • Adds support for exposing view_mode on menu links in headless applications
  • Improves flexibility for frontend rendering logic
  • Cleanly integrates with graphql compose architecture
Feature request
Status

Active

Version

2.3

Component

Code

Created by

🇧🇪Belgium britt.vanderlinden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @britt.vanderlinden
  • 🇧🇪Belgium tim-diels Belgium 🇧🇪

    Please provide patches as MR as that will be easier for review and also triggers the pipelines for quality assurance and testing.

  • Status changed to Needs work about 1 month ago
  • 🇦🇺Australia almunnings Melbourne, 🇦🇺
  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    Hi there,
    I tried to get this to return a result on my end, and it always came back null.

    Am I missing something?
    getEntity isn't on the MenuLinkInterface
    Are you trying to get `MenuLinkContent` entity view_mode?
    Does this require 3rd party modules?

    I'm not aware of that being populated by default in how we access the data.

    I'm also shifting my thinking to the opinion that frontend logic to choose what to display to a user, should happen on the imlenmentation, not the data. We have no rendering context in the menu, so it's unknown what view mode it would even display?

    Maybe I got this wrong.

  • Merge request !130Draft: Menu link view mode, failing test → (Open) created by almunnings
  • 🇦🇺Australia almunnings Melbourne, 🇦🇺

    There is a failing PR up if you wish to continue yourself.

Production build 0.71.5 2024