Skip to content

Commit

Permalink
Fix related items in get call.
Browse files Browse the repository at this point in the history
  • Loading branch information
robgietema committed Mar 25, 2024
1 parent 50c5c3b commit 1492e2d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Fix project vocabularies @robgietema
- Fix password reset link @robgietema
- Fix serving videos @robgietema
- Fix related items in get call @robgietema

### Internal

Expand Down
7 changes: 6 additions & 1 deletion src/models/document/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,12 @@ export class Document extends Model {
const relationListFields = this._type.getFactoryFields('Relation List');
mapSync(relationListFields, async (field) => {
// Check if related documents
if (isArray(json[field]) && json[field].length > 0) {
if (
isArray(json[field]) &&
json[field].length > 0 &&
this._relationLists &&
this.relationLists[field]
) {
json[field] = this._relationLists[field].map((document) => ({
'@id': document.path,
UID: document.uuid,
Expand Down
6 changes: 5 additions & 1 deletion src/routes/content/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,11 @@ export default [
if (req.document._children) {
await Promise.all(
req.document._children.map(
async (child) => await child.fetchRelated('_catalog', trx),
async (child) =>
await Promise.all(
child.fetchRelated('_catalog', trx),
child.fetchRelationLists(trx),
),
),
);
}
Expand Down

0 comments on commit 1492e2d

Please sign in to comment.