-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
defaultPopulate
and populate
with nested to arrays/blocks pr…
…operties (#9751) Fixes #9718 ### What? `defaultPopulate` and `populate` didn't work properly when defining nested to arrays and blocks properties: ```ts import type { CollectionConfig } from 'payload' export const Pages: CollectionConfig<'pages'> = { slug: 'pages', defaultPopulate: { slug: true, array: { title: true, }, blocks: { some: { title: true, }, }, }, access: { read: () => true }, fields: [ { name: 'slug', type: 'text', required: true, }, { name: 'additional', type: 'text', }, { name: 'array', type: 'array', fields: [ { name: 'title', type: 'text', }, { name: 'other', type: 'text', }, ], }, { name: 'blocks', type: 'blocks', blocks: [ { slug: 'some', fields: [ { name: 'title', type: 'text', }, { name: 'other', type: 'text', }, ], }, ], }, ], } ``` ### Why? This should work ### How? Turns out, it wasn't a great idea to mutate passed `select` directly in `afterRead/promise.ts` to force select some properties `id` , `blockType`. Now we do shallow copies when needed.
- Loading branch information
Showing
4 changed files
with
142 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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