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

Command icon 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:

Comments

joaogarin created an issue. See original summary.

joaogarin’s picture

Issue summary: View changes

klausi’s picture

Assigned: joaogarin » klausi

Thanks, I'll work on this.

kingdutch’s picture

Status: Active » Fixed

bypassed reviews on this merge request

😱

And issue status changes too

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

klausi’s picture

Sorry, was waiting on the stupid merge train. Thanks for setting to fixed!

joaogarin’s picture

Thanks all ! Appreciate it 🫶

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.