Fixes bug in loader when a relationship is empty

This commit is contained in:
2025-10-11 15:12:22 -07:00
parent f197a3fabe
commit e9d88fdce8
2 changed files with 11 additions and 3 deletions

View File

@@ -36,8 +36,9 @@ export function DocumentLoader({
relationships: doc.expand?.relationships_via_primary || [],
relatedDocuments:
doc.expand?.relationships_via_primary?.flatMap(
(r: RecordModel) => r.expand?.secondary,
) || [],
// Note: If there are no entries in the expanded secondaries there just won't be an entry instead of an empty list.
(r: RecordModel) => r.expand?.secondary ?? [],
) ?? [],
});
}