Skip to content

Commit 0075b99

Browse files
authored
fix(graphql): loading of polymorphic hasMany relationships (#9175)
### What? Bug #9173 ### Why? `collectionSlug` is an array when `isRelatedToManyCollections` is true ### How? Compare array to array Fixes #9173 ![Screenshot 2024-11-13 at 12 37 52 PM](https://github.com/user-attachments/assets/3eae497d-90d8-474a-afd0-baf69f017459)
1 parent e40141b commit 0075b99

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/graphql/src/schema/buildObjectType.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,11 @@ export function buildObjectType({
432432
const createPopulationPromise = async (relatedDoc, i) => {
433433
let id = relatedDoc
434434
let collectionSlug = field.relationTo
435+
const isValidGraphQLCollection = isRelatedToManyCollections
436+
? graphQLCollections.some((collection) => collectionSlug.includes(collection.slug))
437+
: graphQLCollections.some((collection) => collectionSlug === collection.slug)
435438

436-
if (graphQLCollections.some((collection) => collection.slug === collectionSlug)) {
439+
if (isValidGraphQLCollection) {
437440
if (isRelatedToManyCollections) {
438441
collectionSlug = relatedDoc.relationTo
439442
id = relatedDoc.value

0 commit comments

Comments
 (0)