Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not use
getEntityRecordswith something that change the result format like_fields/contextbecause otherwise it will potentially break other parts of the UI relying on the same entities. Entities should have a consistent format in the store.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that I was missing something, and this was it. In this case, should we not use getEntityRecords, or would it be possible to create an "entity" specific for this? Thank you for the review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's fine to have a specific apiFetch call here? cc @aduth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking about this for another use-case, to try to limit the fields to omit
post.content.renderedfor the edited post, as a performance optimization.The tricky part is the same as what you're experiencing here, in that the data can't be reused.
But I was under the impression it wouldn't necessarily break other usage, it would just treat it as a distinct query, where a separate request would would be made, and no reuse between known fields.
Ideally, I would like to explore some solution which tries to make the most reuse out of the known fields of a request, and only requests the sum difference from what's known. (See #15114)
In the meantime, I think this change is only worthwhile if we aren't using other fields elsewhere for the parent post. If we aren't, I would first check to confirm two
_fieldsrequests can coexist, albeit fetched separately. If we are, then it may not be a worthwhile optimization, or we should artificially align the_fieldsfor what's needed across the two, so we can still take advantage of fields while only issuing one request.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if you use getEntityRecord to get a single entity, it will trigger the fetch request but will also return the existing cached value I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, well, that should definitely be fixed. Whether we decide to do that in parallel with introducing a specific
apiRequestinterim solution here or as a blocker (depending on the urgency of this issue), I don't have a strong preference.