Merge pull request #1526 from gradido/fix-empty-ids-for-get-creations

fix: Return Empty Array When No Pending Creations Are Present
This commit is contained in:
Moriz Wahl 2022-02-22 19:04:38 +01:00 committed by GitHub
commit b425124721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -200,6 +200,10 @@ export class AdminResolver {
@Query(() => [PendingCreation])
async getPendingCreations(): Promise<PendingCreation[]> {
const pendingCreations = await AdminPendingCreation.find()
if (pendingCreations.length === 0) {
return []
}
const userIds = pendingCreations.map((p) => p.userId)
const userCreations = await getUserCreations(userIds)
const users = await User.find({ id: In(userIds) })