-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: add defaultPopulate
property to collection config
#8934
Merged
Conversation
This file contains 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
DanRibbens
requested changes
Oct 30, 2024
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.
Looks great, just the docs fix was all I can tell is wrong.
DanRibbens
approved these changes
Oct 30, 2024
🚀 This is included in version v3.0.0-beta.121 |
DanRibbens
pushed a commit
that referenced
this pull request
Nov 6, 2024
### What? Adds `populate` property to Local API and REST API operations that can be used to specify `select` for a specific collection when it's populated ```ts const result = await payload.findByID({ populate: { // type safe if you have generated types posts: { text: true, }, }, collection: 'pages', depth: 1, id: aboutPage.id, }) result.relatedPost // only has text and id properties ``` ```ts fetch('https://localhost:3000/api/pages?populate[posts][text]=true') // highlight-line .then((res) => res.json()) .then((data) => console.log(data)) ``` It also overrides [`defaultPopulate`](#8934) Ensures `defaultPopulate` doesn't affect GraphQL. ### How? Implements the property for all operations that have the `depth` argument.
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.
What?
Adds
defaultPopulate
property to collection config that allows to specify which fields to select when the collection is populated from another document.Why?
This is essential for example in case of links. You don't need the whole document, which can contain large data but only the
slug
.How?
Implements
defaultPopulate
when populating relationships, including inside of lexical / slate rich text fields.