Problem/Motivation
The following issue will introduce a new menu endpoint to Drupal core: https://www.drupal.org/project/drupal/issues/3227824 Drupal State should support this endpoint, in addition to the existing ways that Drupal State can be used to source JSON:API menu data.
Create a getMenu method to retrieve data related to a specific Drupal menu. Should take menu ID as a parameter and support queries.
Note: this endpoint doesn't provide a JSON:API compatible response, which will complicate things a bit given how the rest of Drupal State assumes JSON:API.
Proposed resolution
So I think the initial role of getMenu is to work with options to source menu data that either are not listed in the jsonapi index or do not provide a response in json:api format (like the current response of the decoupled_menus endpoint that is being targeted for inclusion in core: https://www.drupal.org/project/drupal/issues/3227824)
So that means what will be implemented here is a getMenu method that takes a menuId, and an optional response object. Given the menuId data will be fetched from the jsonapi endpoint following the structure: system/menu/{menuId}/linkset Data will be added to the store using a structure similar to other jsonapi resources. Future getMenu requests will retrieve data from the store first if it exists. Features like locale will continue to work with this approach.
This is probably closest conceptually to what we're doing for getObjectByPath: https://project.pages.drupalcode.org/drupal_state/en/api/interfaces/type...
Things to consider:
* This endpoint doesn't provide a JSON:API compatible response, which will complicate things a bit given how the rest of Drupal State assumes JSON:API.
* It may not be possible to support GraphQL queries for this endpoint.
* It should be possible to use https://www.drupal.org/project/decoupled_menu_parser to parse the data in the response.
Remaining tasks
* Implementation
* Automated test coverage
* Documentation updates
API changes
getMenu method will be added to the DrupalState class.
Data model changes
TBD
Comments
Comment #2
brianperry