Support Menu Item Extra fields for Menu items

Created on 17 January 2024, 11 months ago
Updated 11 April 2024, 9 months ago

We need a way for supporting Menu Item Extras โ†’ in menu items

โœจ Feature request
Status

Fixed

Version

2.1

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ทCosta Rica mcortes19

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

Merge Requests

Comments & Activities

  • Issue created by @mcortes19
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium cedricl

    We did this, but made it hardcoded only for the fields we needed, you can take a look in our module for inspiration.

  • ๐Ÿ‡จ๐Ÿ‡ทCosta Rica mcortes19

    Thanks @CedricL, I'll definitely use it as inspiration and hopefully as a basis for contributing.

  • First commit to issue fork.
  • Merge request !62Resolve #3415306 "Support menu item" โ†’ (Merged) created by almunnings
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Howdy, MR is in, please test and let me know.
    Because we don't "out of the box" support a union of MenuItem types, I've added it to an `extras` field.

    Then I messed about with some of the form UX to make it less.. crap to work with.

    Enable the MenuLinkContent entity fields on Menu in the GraphQL Compose schema form.

    Query on the MenuItem.extras union.

    {
      menu(name: MAIN) {
        items {
          extras {
            ... on MenuLinkContentMain {
              kitties
            }
          }
        }
      }
    }
    

    Also added on MenuItem.langcode โ†’ Language

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ
  • ๐Ÿ‡จ๐Ÿ‡ทCosta Rica mcortes19

    I tested on the D10.8 site and it returned the following error: For error #0: Error: Call to protected method Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::getEntity() from scope Drupal\graphql_compose_menus\Plugin\GraphQL\DataProducer\MenuTreeLinkEntity in Drupal\graphql_compose_menus\Plugin\GraphQL\DataProducer\MenuTreeLinkEntity->resolve() (line 45 of /app/web/modules/contrib/graphql_compose/modules/graphql_compose_menus/src/Plugin/GraphQL/DataProducer/MenuTreeLinkEntity.php)

    Seems like the `getEntity()` method is public until D10.2 โ†’ and many sites are not ready to move to D10.2

  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Ok,
    So thats updated now to use a buffer again.

    Wondering if the semantics are now correct.
    is extras ok?
    should it be fields

    Or do we completely mess with the menu system and clean it up to make more sense if this is an actual entity now.

    Keen for feedback, as i dont feel like going...

    menu(name: MAIN) {
      items {
        extras {
          thing
        }
      }
    }
    

    Really means anything to anyone. It feels like a total after thought. Theres gotta be an "if i didn't have to support any legacy stuff, this is the ideal structure" moment, somewhere?

    Have a plan
    Keen on feedback

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Without trying to over think this more, I feel like โ€˜fieldsโ€™ makes the most sense here.

    Will write up some tests tonight and get this in.

  • Status changed to Fixed 9 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ
  • Status changed to Fixed 9 months ago
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia almunnings Melbourne, ๐Ÿ‡ฆ๐Ÿ‡บ

    Beta 2 tagged, thanks all

Production build 0.71.5 2024