@@ -95,24 +95,17 @@ export class EntityDataLoader<T extends AnyEntity<T> = any, P extends string = n
95
95
> ( async ( dataloaderFinds ) => {
96
96
const queriesMap = groupFindQueries ( dataloaderFinds ) ;
97
97
assertHasNewFilterAndMapKey ( dataloaderFinds ) ;
98
- const resultsMap = new Map < string , any [ ] | Error > ( ) ;
99
- await Promise . all (
100
- Array . from ( queriesMap , async ( [ key , [ filter , options ] ] ) : Promise < void > => {
101
- const entityName = key . substring ( 0 , key . indexOf ( "|" ) ) ;
102
- let entitiesOrError : any [ ] | Error ;
103
- const findOptions = {
104
- ...( options ?. populate != null && {
105
- populate : options . populate === true ? [ "*" ] : Array . from ( options . populate ) ,
106
- } ) ,
107
- } satisfies Pick < FindOptions < any , any > , "populate" > ;
108
- try {
109
- entitiesOrError = await em . getRepository ( entityName ) . find ( filter , findOptions ) ;
110
- } catch ( e ) {
111
- entitiesOrError = e as Error ;
112
- }
113
- resultsMap . set ( key , entitiesOrError ) ;
114
- } ) ,
115
- ) ;
98
+ const promises = Array . from ( queriesMap , async ( [ key , [ filter , options ] ] ) : Promise < [ string , any [ ] ] > => {
99
+ const entityName = key . substring ( 0 , key . indexOf ( "|" ) ) ;
100
+ const findOptions = {
101
+ ...( options ?. populate != null && {
102
+ populate : options . populate === true ? [ "*" ] : Array . from ( options . populate ) ,
103
+ } ) ,
104
+ } satisfies Pick < FindOptions < any , any > , "populate" > ;
105
+ const entities = await em . getRepository ( entityName ) . find ( filter , findOptions ) ;
106
+ return [ key , entities ] ;
107
+ } ) ;
108
+ const resultsMap = new Map ( await Promise . all ( promises ) ) ;
116
109
117
110
return dataloaderFinds . map ( ( { filtersAndKeys, many } ) => {
118
111
const res = filtersAndKeys . reduce < any [ ] > ( ( acc , { key, newFilter } ) => {
0 commit comments