Add support for reducing number of return elements per menu item

Created on 27 March 2023, over 1 year ago
Updated 2 May 2024, 7 months ago

Problem/Motivation

As a consumer of menu items API, I want to reduce the volume of response for a large menu dataset, so that I reduce the network overhead of downloading this menu when it has many items.

Internally we want to use this module in order to reduce the number of requests made to the API to fetch menus. However, in the spirit of optimising our request footprint, many of the fields aren't relevant to our FE consuming code.

In order to reduce the network response, we want to be able to request what elements return per menu item so that only relevant data points are returned.

Steps to reproduce

1. Install Drupal and JSON:API Menu Items module
2. Create Node with Menu link
3. Request menu items with a filter to only supply provided fields, i.e. filter[fields]=title,url,parent,children

Proposed resolution

1. Create a method that allows filtering of the `fields` array in ~L186 of MenuItemsResource.php
2. A proposed patch is forthcoming today to demonstrate a potential solution

Remaining tasks

1. Add tests to ensure filtering works as expected.

User interface changes

N/A

API changes

1. Potential reduction of fields returned as part of API signature

Data model changes

N/A

Feature request
Status

Active

Version

1.2

Component

Code

Created by

🇦🇺Australia matthew.hallsworth.dpc

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

Comments & Activities

Production build 0.71.5 2024