[wp-trac] [WordPress Trac] #38131: REST API: Provide interface to include or exclude specific fields from response JSON
WordPress Trac
noreply at wordpress.org
Wed Aug 9 22:23:24 UTC 2017
#38131: REST API: Provide interface to include or exclude specific fields from
response JSON
-------------------------+-----------------------------
Reporter: kadamwhite | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: REST API | Version: 4.4
Severity: normal | Resolution:
Keywords: | Focuses: performance
-------------------------+-----------------------------
Comment (by afercia):
As mentioned in #38920 and #38922 excluding specific fields from the
response would benefit in different scenarios. Especially the links
suggestion search (#38920). The current PHP/AJAX search returns just a few
fields and the response size is minimal.
In Gutenberg instead, when inserting a link the response returns all the
fields, including the post content. For feature parity with the current
editor, there would be the need of just the post ID, title, permalink, and
date. Even better, Gutenberg currently displays just the post title and
permalink, so it would need even less fields.
Instead, everything is returned. I understand that's the nature of an API
that has been designed for a different data consuming model. However, for
an efficient use in core and in Gutenberg, the response should really be
tailored to the actual, specific need on a case by case basis.
Thinking at websites with very long post contents (great publishers...
prolific bloggers...) the actual response size can be potentially huge,
even some MB. With PHP/AJAX, in the worst case, it's a few KB. In this
specific kind of scenario, I don't see why WordPress should use a tool
that is slower and heavier compared to the current implementation.
Having the ability to exclude fields would solve the issue.
Worth noting the link suggestions in Gutenberg currently returns only
posts, while the old search returns posts, pages, and CPTs. This is a
separate issue though, see #39965.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/38131#comment:23>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list