@@ -86,7 +86,7 @@ import { DEFAULT_DEPRECATION_REASON } from 'graphql';
8686export function newPersistedDirectivesData ( ) : PersistedDirectivesData {
8787 return {
8888 deprecatedReason : '' ,
89- directivesByDirectiveName : new Map < DirectiveName , ConstDirectiveNode [ ] > ( ) ,
89+ directivesByName : new Map < DirectiveName , ConstDirectiveNode [ ] > ( ) ,
9090 isDeprecated : false ,
9191 tagDirectiveByName : new Map < string , ConstDirectiveNode > ( ) ,
9292 } ;
@@ -100,11 +100,11 @@ type IsNodeExternalOrShareableResult = {
100100export function isNodeExternalOrShareable (
101101 node : ObjectTypeNode | FieldDefinitionNode ,
102102 areAllFieldsShareable : boolean ,
103- directivesByDirectiveName : Map < DirectiveName , ConstDirectiveNode [ ] > ,
103+ directivesByName : Map < DirectiveName , ConstDirectiveNode [ ] > ,
104104) : IsNodeExternalOrShareableResult {
105105 const result : IsNodeExternalOrShareableResult = {
106- isExternal : directivesByDirectiveName . has ( EXTERNAL ) ,
107- isShareable : areAllFieldsShareable || directivesByDirectiveName . has ( SHAREABLE ) ,
106+ isExternal : directivesByName . has ( EXTERNAL ) ,
107+ isShareable : areAllFieldsShareable || directivesByName . has ( SHAREABLE ) ,
108108 } ;
109109 if ( ! node . directives ?. length ) {
110110 return result ;
@@ -224,7 +224,7 @@ type ChildDefinitionNode = EnumValueDefinitionNode | FieldDefinitionNode | Input
224224function propagateFieldDataArguments ( fieldData : FieldData ) {
225225 for ( const argumentData of fieldData . argumentDataByName . values ( ) ) {
226226 // First propagate the argument's directives
227- for ( const directiveNodes of argumentData . directivesByDirectiveName . values ( ) ) {
227+ for ( const directiveNodes of argumentData . directivesByName . values ( ) ) {
228228 argumentData . node . directives . push ( ...directiveNodes ) ;
229229 }
230230 fieldData . node . arguments . push ( argumentData . node ) ;
@@ -239,7 +239,7 @@ export function childMapToValueArray<T extends ChildData, U extends ChildDefinit
239239 if ( isFieldData ( childData ) ) {
240240 propagateFieldDataArguments ( childData ) ;
241241 }
242- for ( const [ directiveName , directiveNodes ] of childData . directivesByDirectiveName ) {
242+ for ( const [ directiveName , directiveNodes ] of childData . directivesByName ) {
243243 if ( directiveName === DEPRECATED ) {
244244 // @deprecated is non-repeatable
245245 const directiveNode = directiveNodes [ 0 ] ;
@@ -341,12 +341,10 @@ export function propagateAuthDirectives(parentData: ParentDefinitionData, authDa
341341 return ;
342342 }
343343 if ( authData . requiresAuthentication ) {
344- parentData . persistedDirectivesData . directivesByDirectiveName . set ( AUTHENTICATED , [
345- generateSimpleDirective ( AUTHENTICATED ) ,
346- ] ) ;
344+ parentData . persistedDirectivesData . directivesByName . set ( AUTHENTICATED , [ generateSimpleDirective ( AUTHENTICATED ) ] ) ;
347345 }
348346 if ( authData . requiredScopes . length > 0 ) {
349- parentData . persistedDirectivesData . directivesByDirectiveName . set ( REQUIRES_SCOPES , [
347+ parentData . persistedDirectivesData . directivesByName . set ( REQUIRES_SCOPES , [
350348 generateRequiresScopesDirective ( authData . requiredScopes ) ,
351349 ] ) ;
352350 }
@@ -361,12 +359,10 @@ export function propagateFieldAuthDirectives(fieldData: FieldData, authData?: Au
361359 return ;
362360 }
363361 if ( fieldAuthData . originalData . requiresAuthentication ) {
364- fieldData . persistedDirectivesData . directivesByDirectiveName . set ( AUTHENTICATED , [
365- generateSimpleDirective ( AUTHENTICATED ) ,
366- ] ) ;
362+ fieldData . persistedDirectivesData . directivesByName . set ( AUTHENTICATED , [ generateSimpleDirective ( AUTHENTICATED ) ] ) ;
367363 }
368364 if ( fieldAuthData . originalData . requiredScopes . length > 0 ) {
369- fieldData . persistedDirectivesData . directivesByDirectiveName . set ( REQUIRES_SCOPES , [
365+ fieldData . persistedDirectivesData . directivesByName . set ( REQUIRES_SCOPES , [
370366 generateRequiresScopesDirective ( fieldAuthData . originalData . requiredScopes ) ,
371367 ] ) ;
372368 }
@@ -390,14 +386,14 @@ export function generateDeprecatedDirective(reason: string): ConstDirectiveNode
390386}
391387
392388function getValidFlattenedPersistedDirectiveNodeArray (
393- directivesByDirectiveName : Map < DirectiveName , ConstDirectiveNode [ ] > ,
394- persistedDirectiveDefinitionByDirectiveName : Map < DirectiveName , DirectiveDefinitionNode > ,
389+ directivesByName : Map < DirectiveName , Array < ConstDirectiveNode > > ,
390+ persistedDirectiveDefinitionByName : Map < DirectiveName , DirectiveDefinitionNode > ,
395391 directiveCoords : string ,
396392 errors : Error [ ] ,
397393) : ConstDirectiveNode [ ] {
398- const persistedDirectiveNodes : ConstDirectiveNode [ ] = [ ] ;
399- for ( const [ directiveName , directiveNodes ] of directivesByDirectiveName ) {
400- const persistedDirectiveDefinition = persistedDirectiveDefinitionByDirectiveName . get ( directiveName ) ;
394+ const persistedDirectiveNodes : Array < ConstDirectiveNode > = [ ] ;
395+ for ( const [ directiveName , directiveNodes ] of directivesByName ) {
396+ const persistedDirectiveDefinition = persistedDirectiveDefinitionByName . get ( directiveName ) ;
401397 if ( ! persistedDirectiveDefinition ) {
402398 continue ;
403399 }
@@ -416,7 +412,7 @@ function getValidFlattenedPersistedDirectiveNodeArray(
416412
417413function getRouterPersistedDirectiveNodes < T extends NodeData > (
418414 nodeData : T ,
419- persistedDirectiveDefinitionByDirectiveName : Map < string , DirectiveDefinitionNode > ,
415+ persistedDirectiveDefinitionByName : Map < DirectiveName , DirectiveDefinitionNode > ,
420416 errors : Error [ ] ,
421417) : ConstDirectiveNode [ ] {
422418 const persistedDirectiveNodes = [ ...nodeData . persistedDirectivesData . tagDirectiveByName . values ( ) ] ;
@@ -425,8 +421,8 @@ function getRouterPersistedDirectiveNodes<T extends NodeData>(
425421 }
426422 persistedDirectiveNodes . push (
427423 ...getValidFlattenedPersistedDirectiveNodeArray (
428- nodeData . persistedDirectivesData . directivesByDirectiveName ,
429- persistedDirectiveDefinitionByDirectiveName ,
424+ nodeData . persistedDirectivesData . directivesByName ,
425+ persistedDirectiveDefinitionByName ,
430426 nodeData . name ,
431427 errors ,
432428 ) ,
@@ -435,11 +431,11 @@ function getRouterPersistedDirectiveNodes<T extends NodeData>(
435431}
436432
437433export function getClientPersistedDirectiveNodes < T extends NodeData > ( nodeData : T ) : ConstDirectiveNode [ ] {
438- const persistedDirectiveNodes : ConstDirectiveNode [ ] = [ ] ;
434+ const persistedDirectiveNodes : Array < ConstDirectiveNode > = [ ] ;
439435 if ( nodeData . persistedDirectivesData . isDeprecated ) {
440436 persistedDirectiveNodes . push ( generateDeprecatedDirective ( nodeData . persistedDirectivesData . deprecatedReason ) ) ;
441437 }
442- for ( const [ directiveName , directiveNodes ] of nodeData . persistedDirectivesData . directivesByDirectiveName ) {
438+ for ( const [ directiveName , directiveNodes ] of nodeData . persistedDirectivesData . directivesByName ) {
443439 if ( directiveName === SEMANTIC_NON_NULL && isFieldData ( nodeData ) ) {
444440 persistedDirectiveNodes . push (
445441 generateSemanticNonNullDirective ( getFirstEntry ( nodeData . nullLevelsBySubgraphName ) ?? new Set < number > ( [ 0 ] ) ) ,
@@ -657,10 +653,7 @@ export function isTypeValidImplementation(
657653}
658654
659655export function isNodeDataInaccessible ( data : NodeData ) : boolean {
660- return (
661- data . persistedDirectivesData . directivesByDirectiveName . has ( INACCESSIBLE ) ||
662- data . directivesByDirectiveName . has ( INACCESSIBLE )
663- ) ;
656+ return data . persistedDirectivesData . directivesByName . has ( INACCESSIBLE ) || data . directivesByName . has ( INACCESSIBLE ) ;
664657}
665658
666659export function isLeafKind ( kind : Kind ) : boolean {
0 commit comments