fix: skip populate hidden reference#1720
Open
saputradharma wants to merge 1 commit intoSoftwareBrothers:masterfrom
Open
fix: skip populate hidden reference#1720saputradharma wants to merge 1 commit intoSoftwareBrothers:masterfrom
saputradharma wants to merge 1 commit intoSoftwareBrothers:masterfrom
Conversation
dziraf
requested changes
Dec 5, 2024
|
|
||
| const references = allProperties.filter((p) => !!p.reference()) | ||
|
|
||
| const references = allProperties.filter((p) => !!p.reference() && (p.isVisible('show') || p.isVisible('list') || p.isVisible('edit') || p.isVisible('filter'))) |
Contributor
There was a problem hiding this comment.
I think you can take it a step further and check isVisible only for the current action since it's available in context:
https://github.com/SoftwareBrothers/adminjs/blob/master/src/backend/actions/action.interface.ts#L54
I'm unsure if we'd like to add this restriction though. In actions isVisible is different than isAccessible. Similarly, someone may want to use the ApiClient to fetch record details (show) and they'd like all populated properties to be present.
Ideally, there should be isAccessible in the property options which would tell whether the API should fetch that reference. Setting isAccessible: false should also automatically override isVisible to false since it wouldn't be available.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supporting to skip loading invisible reference property.
Currently, it loads all of the related resources even though the property has been set as
isVisible: false which will result to unnecessary data load and query.