mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-22 19:19:05 +00:00
Load relations sequentially (#212)
This commit is contained in:
parent
2517f110ea
commit
be65ca45ea
@ -632,8 +632,9 @@ export class Database {
|
||||
return entities;
|
||||
}
|
||||
|
||||
const relationPromises = selections.filter((selection) => selection.kind === 'Field' && Boolean(relations[selection.name.value]))
|
||||
.map(async selection => {
|
||||
const relationSelections = selections.filter((selection) => selection.kind === 'Field' && Boolean(relations[selection.name.value]));
|
||||
|
||||
for (const selection of relationSelections) {
|
||||
assert(selection.kind === 'Field');
|
||||
const field = selection.name.value;
|
||||
const { entity: relationEntity, isArray, isDerived, field: foreignKey } = relations[field];
|
||||
@ -684,7 +685,7 @@ export class Database {
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isArray) {
|
||||
@ -728,7 +729,7 @@ export class Database {
|
||||
});
|
||||
});
|
||||
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
// field is neither an array nor derivedFrom
|
||||
@ -738,7 +739,7 @@ export class Database {
|
||||
entity[field] = { id: entity[field] };
|
||||
});
|
||||
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
const where: Where = {
|
||||
@ -770,9 +771,7 @@ export class Database {
|
||||
entity[field] = relatedEntitiesMap[entity[field]];
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await Promise.all(relationPromises);
|
||||
}
|
||||
|
||||
return entities;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user