@@ -206,23 +206,23 @@ export class MetadataStorage {
206206
207207 if ( this . params ?. length ) {
208208 this . params . forEach ( param => {
209- const key = `${ param . target } - ${ param . methodName } ` ;
209+ const key = `${ param . target } # ${ param . methodName } ` ;
210210 if ( ! this . paramsCache . has ( key ) ) {
211211 this . paramsCache . set ( key , [ ] ) ;
212212 }
213- this . paramsCache . get ( key ) ? .push ( param ) ;
213+ this . paramsCache . get ( key ) ! . push ( param ) ;
214214 } ) ;
215215 }
216216
217217 if ( this . middlewares ?. length ) {
218218 this . middlewares . forEach ( middleware => {
219- const key = `${ middleware . target } - ${ middleware . fieldName } ` ;
219+ const key = `${ middleware . target } # ${ middleware . fieldName } ` ;
220220 if ( ! this . middlewaresByTargetAndFieldCache . has ( key ) ) {
221221 this . middlewaresByTargetAndFieldCache . set ( key , new Set ( ) ) ;
222222 }
223223
224- if ( ! this . middlewaresByTargetAndFieldCache . get ( key ) ? .has ( middleware ) ) {
225- this . middlewaresByTargetAndFieldCache . get ( key ) ? .add ( middleware ) ;
224+ if ( ! this . middlewaresByTargetAndFieldCache . get ( key ) ! . has ( middleware ) ) {
225+ this . middlewaresByTargetAndFieldCache . get ( key ) ! . add ( middleware ) ;
226226 }
227227 } ) ;
228228 }
@@ -234,19 +234,19 @@ export class MetadataStorage {
234234 this . resolverMiddlewaresByTargetCache . set ( key , new Set ( ) ) ;
235235 }
236236
237- if ( ! this . resolverMiddlewaresByTargetCache . get ( key ) ? .has ( middleware ) ) {
238- this . resolverMiddlewaresByTargetCache . get ( key ) ? .add ( middleware ) ;
237+ if ( ! this . resolverMiddlewaresByTargetCache . get ( key ) ! . has ( middleware ) ) {
238+ this . resolverMiddlewaresByTargetCache . get ( key ) ! . add ( middleware ) ;
239239 }
240240 } ) ;
241241 }
242242
243243 if ( this . fieldDirectives ?. length ) {
244244 this . fieldDirectives . forEach ( directive => {
245- const key = `${ directive . target } - ${ directive . fieldName } ` ;
245+ const key = `${ directive . target } # ${ directive . fieldName } ` ;
246246 if ( ! this . fieldDirectivesByTargetAndFieldCache . has ( key ) ) {
247247 this . fieldDirectivesByTargetAndFieldCache . set ( key , [ ] ) ;
248248 }
249- this . fieldDirectivesByTargetAndFieldCache . get ( key ) ? .push ( directive ) ;
249+ this . fieldDirectivesByTargetAndFieldCache . get ( key ) ! . push ( directive ) ;
250250 } ) ;
251251 }
252252
@@ -256,13 +256,13 @@ export class MetadataStorage {
256256 if ( ! this . classDirectivesByTargetCache . has ( key ) ) {
257257 this . classDirectivesByTargetCache . set ( key , [ ] ) ;
258258 }
259- this . classDirectivesByTargetCache . get ( key ) ? .push ( directive ) ;
259+ this . classDirectivesByTargetCache . get ( key ) ! . push ( directive ) ;
260260 } ) ;
261261 }
262262
263263 if ( this . authorizedFields ?. length ) {
264264 this . authorizedFields . forEach ( field => {
265- const key = `${ field . target } - ${ field . fieldName } ` ;
265+ const key = `${ field . target } # ${ field . fieldName } ` ;
266266 if ( ! this . authorizedFieldsByTargetAndFieldCache . has ( key ) ) {
267267 this . authorizedFieldsByTargetAndFieldCache . set ( key , field ) ;
268268 }
@@ -283,7 +283,7 @@ export class MetadataStorage {
283283 if ( ! this . fieldsCache . has ( field . target ) ) {
284284 this . fieldsCache . set ( field . target , [ ] ) ;
285285 }
286- this . fieldsCache . get ( field . target ) ? .push ( field ) ;
286+ this . fieldsCache . get ( field . target ) ! . push ( field ) ;
287287 } ) ;
288288 }
289289
@@ -368,30 +368,26 @@ export class MetadataStorage {
368368 const fields = this . fieldsCache . get ( def . target ) || [ ] ;
369369 fields . forEach ( field => {
370370 field . roles = this . findFieldRoles ( field . target , field . name ) ;
371-
372- const paramKey = `${ field . target } -${ field . name } ` ;
373- field . params = this . paramsCache . get ( paramKey ) || [ ] ;
374-
375- const resolverMiddlewares = this . resolverMiddlewaresByTargetCache . get ( field . target ) || [ ] ;
376- const middlewaresKey = `${ field . target } -${ field . name } ` ;
377- const fieldMiddlewares = this . middlewaresByTargetAndFieldCache . get ( middlewaresKey ) || [ ] ;
378-
371+ field . params = this . paramsCache . get ( `${ field . target } #${ field . name } ` ) || [ ] ;
379372 field . middlewares = [
380- ...mapMiddlewareMetadataToArray ( Array . from ( resolverMiddlewares ) ) ,
381- ...mapMiddlewareMetadataToArray ( Array . from ( fieldMiddlewares ) ) ,
373+ ...mapMiddlewareMetadataToArray ( [
374+ ...( this . resolverMiddlewaresByTargetCache . get ( field . target ) || [ ] ) ,
375+ ] ) ,
376+ ...mapMiddlewareMetadataToArray ( [
377+ ...( this . middlewaresByTargetAndFieldCache . get ( `${ field . target } #${ field . name } ` ) || [ ] ) ,
378+ ] ) ,
382379 ] ;
383-
384- const directives =
385- this . fieldDirectivesByTargetAndFieldCache . get ( `${ field . target } -${ field . name } ` ) || [ ] ;
386- field . directives = directives . map ( it => it . directive ) ;
387-
380+ field . directives = (
381+ this . fieldDirectivesByTargetAndFieldCache . get ( `${ field . target } #${ field . name } ` ) || [ ]
382+ ) . map ( it => it . directive ) ;
388383 field . extensions = this . findExtensions ( field . target , field . name ) ;
389384 } ) ;
390385 def . fields = fields ;
391386 }
392387 if ( ! def . directives ) {
393- const directives = this . classDirectivesByTargetCache . get ( def . target ) || [ ] ;
394- def . directives = directives . map ( directive => directive . directive ) ;
388+ def . directives = ( this . classDirectivesByTargetCache . get ( def . target ) || [ ] ) . map (
389+ it => it . directive ,
390+ ) ;
395391 }
396392 if ( ! def . extensions ) {
397393 def . extensions = this . findExtensions ( def . target ) ;
@@ -402,19 +398,19 @@ export class MetadataStorage {
402398 private buildResolversMetadata ( definitions : BaseResolverMetadata [ ] ) {
403399 definitions . forEach ( def => {
404400 def . resolverClassMetadata = this . resolverClassesCache . get ( def . target ) ;
405- def . params = this . paramsCache . get ( `${ def . target } - ${ def . methodName } ` ) || [ ] ;
401+ def . params = this . paramsCache . get ( `${ def . target } # ${ def . methodName } ` ) || [ ] ;
406402 def . roles = this . findFieldRoles ( def . target , def . methodName ) ;
407-
408- const resolverMiddlewares = this . resolverMiddlewaresByTargetCache . get ( def . target ) || [ ] ;
409- const fieldMiddlewares =
410- this . middlewaresByTargetAndFieldCache . get ( `${ def . target } -${ def . methodName } ` ) || [ ] ;
411403 def . middlewares = [
412- ...mapMiddlewareMetadataToArray ( Array . from ( resolverMiddlewares ) ) ,
413- ...mapMiddlewareMetadataToArray ( Array . from ( fieldMiddlewares ) ) ,
404+ ...mapMiddlewareMetadataToArray ( [
405+ ...( this . resolverMiddlewaresByTargetCache . get ( def . target ) || [ ] ) ,
406+ ] ) ,
407+ ...mapMiddlewareMetadataToArray ( [
408+ ...( this . middlewaresByTargetAndFieldCache . get ( `${ def . target } #${ def . methodName } ` ) || [ ] ) ,
409+ ] ) ,
414410 ] ;
415411
416412 def . directives = (
417- this . fieldDirectivesByTargetAndFieldCache . get ( `${ def . target } - ${ def . methodName } ` ) || [ ]
413+ this . fieldDirectivesByTargetAndFieldCache . get ( `${ def . target } # ${ def . methodName } ` ) || [ ]
418414 ) . map ( it => it . directive ) ;
419415 def . extensions = this . findExtensions ( def . target , def . methodName ) ;
420416 } ) ;
@@ -428,7 +424,7 @@ export class MetadataStorage {
428424 definitions . forEach ( def => {
429425 def . roles = this . findFieldRoles ( def . target , def . methodName ) ;
430426 def . directives = (
431- this . fieldDirectivesByTargetAndFieldCache . get ( `${ def . target } - ${ def . methodName } ` ) || [ ]
427+ this . fieldDirectivesByTargetAndFieldCache . get ( `${ def . target } # ${ def . methodName } ` ) || [ ]
432428 ) . map ( it => it . directive ) ;
433429 def . extensions = this . findExtensions ( def . target , def . methodName ) ;
434430 def . getObjectType =
@@ -437,9 +433,6 @@ export class MetadataStorage {
437433 : ( ) => def . target as ClassType ;
438434 if ( def . kind === "external" ) {
439435 const typeClass = this . resolverClassesCache . get ( def . target ) ! . getObjectType ! ( ) ;
440- if ( ! typeClass ) {
441- throw new Error ( `Unable to find type class for external resolver ${ def . target . name } ` ) ;
442- }
443436 const typeMetadata =
444437 this . objectTypesCache . get ( typeClass ) || this . interfaceTypesCache . get ( typeClass ) ;
445438 if ( ! typeMetadata ) {
@@ -520,7 +513,7 @@ export class MetadataStorage {
520513
521514 private findFieldRoles ( target : Function , fieldName : string ) : any [ ] | undefined {
522515 const authorizedField =
523- this . authorizedFieldsByTargetAndFieldCache . get ( `${ target } - ${ fieldName } ` ) ||
516+ this . authorizedFieldsByTargetAndFieldCache . get ( `${ target } # ${ fieldName } ` ) ||
524517 this . authorizedResolverByTargetCache . get ( target ) ;
525518 if ( ! authorizedField ) {
526519 return undefined ;
0 commit comments