### What? Fixed groupBy functionality for polymorphic relationships, which was throwing errors. <img width="1099" height="996" alt="Screenshot 2025-09-11 at 3 10 32 PM" src="https://github.com/user-attachments/assets/bd11d557-7f21-4e09-8fe6-6a43d777d82c" /> ### Why? The groupBy feature failed for polymorphic relationships because: - `relationshipConfig` was undefined when `relationTo` is an array (polymorphic) - ObjectId serialization errors when passing database objects to React client components - hasMany relationships weren't properly flattened into individual groups - "No Value" groups appeared first instead of populated groups ### How? - Handle polymorphic relationship structure `{relationTo, value}` correctly by finding the right collection config using `relationTo` - Add proper collection config lookup for each relation in polymorphic relationships during populate - Flatten hasMany relationship arrays so documents with `[Category1, Category2]` create separate groups for each --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211331842191589
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import { lexicalEditor } from '@payloadcms/richtext-lexical'
|
|
import { fileURLToPath } from 'node:url'
|
|
import path from 'path'
|
|
|
|
import { buildConfigWithDefaults } from '../buildConfigWithDefaults.js'
|
|
import { CategoriesCollection } from './collections/Categories/index.js'
|
|
import { MediaCollection } from './collections/Media/index.js'
|
|
import { PostsCollection } from './collections/Posts/index.js'
|
|
import { RelationshipsCollection } from './collections/Relationships/index.js'
|
|
import { seed } from './seed.js'
|
|
|
|
const filename = fileURLToPath(import.meta.url)
|
|
const dirname = path.dirname(filename)
|
|
|
|
export default buildConfigWithDefaults({
|
|
collections: [PostsCollection, CategoriesCollection, MediaCollection, RelationshipsCollection],
|
|
admin: {
|
|
importMap: {
|
|
baseDir: path.resolve(dirname),
|
|
},
|
|
},
|
|
editor: lexicalEditor({}),
|
|
onInit: async (payload) => {
|
|
if (process.env.SEED_IN_CONFIG_ONINIT !== 'false') {
|
|
await seed(payload)
|
|
}
|
|
},
|
|
typescript: {
|
|
outputFile: path.resolve(dirname, 'payload-types.ts'),
|
|
},
|
|
})
|