menuByName does not work on custom menus

Created on 7 February 2024, 10 months ago
Updated 29 February 2024, 9 months ago

Problem/Motivation

Since version 1.0.0 menuByName does return null for custom menus. This worked in Beta 7

Steps to reproduce

query getMenu {
  menuByName(name: YOUR_CUSTOM_MENU) {
    id
    label
  }
}

returns

{
  "data": {
    "menuByName": null
  }
}
<!--break-->

While

query getMenu {
  menuByName(name: MAIN) {
    id
    label
  }
}

returns correctly

{
  "data": {
    "menuByName": {
      "id": "main",
      "label": "Main menu"
    }
  }
}
🐛 Bug report
Status

Closed: cannot reproduce

Version

1.0

Component

Code

Created by

🇪🇸Spain abelass

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

Comments & Activities

  • Issue created by @abelass
  • 🇨🇭Switzerland ayalon

    I have tested this with the latest 1.0.0 version and it works for me.

    2 things to consider:
    Did you implement an access hook for the menu? Maybe you have an access hook only allowing view access on "main"?
    https://graphql-core-schema.netlify.app/basics/security.html

    /**
     * Implements hook_ENTITY_TYPE_access().
     */
    function MY_MODULE_menu_access(EntityInterface $entity, $operation, AccountInterface $account) {
      // Grant view access to the main menu to everyone.
      $id = $entity->id();
      if ($operation === 'view' && $id === 'main') {
        return AccessResult::allowed();
      }
    
      return AccessResult::neutral();
    }

    Do you have a very cryptic broken machine nime that might give you troubles?

  • Status changed to Closed: cannot reproduce 9 months ago
  • 🇪🇸Spain abelass

    I restested and ti's not a custom or non custom menu qustion

    Access Permission are already implemented and worked before. (As said it worked on Beta 7)

    I may be related to the menu names but I couldn't fin a pattern

    for Example a menu called test-test-test

    query getMenu {
      menuByName(name: TEST_TEST_TEST) {
        id
        label
      }
    }
    

    works

    but not a menu called menu-espace-membres

    query getMenu {
      menuByName(name: MENU_ESPACE_MEMBRES) {
        id
        label
      }
    }
Production build 0.71.5 2024