Problem/Motivation
This is somewhat related to https://github.com/drupal-graphql/graphql/pull/809 which adds multilingual support for menu links. That works well, however in our case we are passing the language parameter to the menu, and that seems to not get carried away to the URL.
The label is translated fine but the URL itself (which in our case is not translated in the menu item its just the original URL) is not really picked up..the link is to a node so it should be possible to return the translated URL
Our resolvers look like this :
Getting the menu :
// Menu query.
$registry->addFieldResolver('Query', 'menu',
$builder->produce('menu_load', [
'id' => $builder->fromArgument('name'),
'access' => $builder->fromValue(FALSE),
'language' => $builder->fromArgument('language'),
])
);getting the menu items :
// Menu items.
$registry->addFieldResolver('Menu', 'items',
$builder->produce('menu_links', [
'menu' => $builder->fromParent(),
])
);Item URL :
// Menu url.
$registry->addFieldResolver('MenuItem', 'url',
$builder->produce('menu_link_url', [
'link' => $builder->produce('menu_tree_link', [
'element' => $builder->fromParent(),
]),
])
);Steps to reproduce
Create a multilingual project, setup menus and make translations on menu links but keep the link url untranslated.
Create a translation of a menu link to a node that has translations. The URl is not transated in the GraphQL resolvers, label is translated but not the URL.
Proposed resolution
The MenuLinkUrl resolver similar to the label resolver can handle the translation
Remaining tasks
N/A
User interface changes
N/A
API changes
Data model changes
Issue fork graphql-3587614
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- fix_url_translation
changes, plain diff MR !94
- 5.x
compare
- 3587614-menu-link-url
changes, plain diff MR !93
Comments
Comment #2
joaogarin commentedComment #6
klausiThanks, I'll work on this.
Comment #8
kingdutch😱
And issue status changes too
Comment #10
klausiSorry, was waiting on the stupid merge train. Thanks for setting to fixed!
Comment #11
joaogarin commentedThanks all ! Appreciate it 🫶