Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve response fields filtering #295

Open
eri-trabiccolo opened this issue May 26, 2022 · 1 comment
Open

Improve response fields filtering #295

eri-trabiccolo opened this issue May 26, 2022 · 1 comment
Assignees
Labels
Type: Enhancement Improvements existing features or code

Comments

@eri-trabiccolo
Copy link
Contributor

By default WordPress's REST API allow for filtering the response fields trough the _fields global parameter:
https://developer.wordpress.org/rest-api/using-the-rest-api/global-parameters/#_fields

This already works because any response is filtered and the fields not included in _fields (when supplied), will be automatically excluded.

Although, in our case, the filtering doesn't work fine with nested properties for post based resources, which would ve very handy for filtering meta fields, which are sub-properties of the meta property.

That's because back in the days when I started implementing the first resources I decided, mainly out of laziness, to avoid checking every time whether a property was to be included in the response prior to compute it (e.g. https://github.com/WordPress/wordpress-develop/blob/6.0/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php#L1710) and instead process them all, and roughly filter them at end:
https://github.com/gocodebox/lifterlms-rest/blob/1.0.0-beta-24/includes/abstracts/class-llms-rest-posts-controller.php#L903

Of course the main problem here is my rough filtering, although checking every time whether a property is to be included in the response prior to process it might be a performance improvement.

@thomasplevy thomasplevy moved this to Awaiting Triage in Development May 26, 2022
@eri-trabiccolo eri-trabiccolo removed their assignment May 26, 2022
@eri-trabiccolo eri-trabiccolo moved this from Awaiting Triage to In Progress in Development May 26, 2022
@eri-trabiccolo eri-trabiccolo added the Type: Enhancement Improvements existing features or code label May 26, 2022
@eri-trabiccolo eri-trabiccolo moved this from In Progress to To do in Development Jun 6, 2022
@eri-trabiccolo eri-trabiccolo moved this from To do to In Progress in Development Jun 20, 2022
@thomasplevy thomasplevy moved this from In Progress to Backlog in Development Jul 5, 2022
@eri-trabiccolo eri-trabiccolo moved this from Backlog to To do in Development Jul 3, 2023
@eri-trabiccolo
Copy link
Contributor Author

HS-219383

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improvements existing features or code
Projects
Status: To do
Development

No branches or pull requests

2 participants