fix: Return Empty Array When No Pending Creations Are Present

This commit is contained in:
Moriz Wahl 2022-02-22 18:49:24 +01:00
parent 9cccdd97c7
commit b8c3deac3e

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) })