@@ -252,6 +252,7 @@ export function extendSchema(
252
252
subscription : subscriptionType ,
253
253
types,
254
254
directives : getMergedDirectives ( ) ,
255
+ astNode : schema . astNode ,
255
256
} ) ;
256
257
257
258
// Below are functions used for producing this schema that have closed over
@@ -344,11 +345,19 @@ export function extendSchema(
344
345
}
345
346
346
347
function extendObjectType ( type : GraphQLObjectType ) : GraphQLObjectType {
348
+ const name = type . name ;
349
+ let extensionASTNodes = type . extensionASTNodes ;
350
+ if ( typeExtensionsMap [ name ] ) {
351
+ extensionASTNodes = extensionASTNodes . concat ( typeExtensionsMap [ name ] ) ;
352
+ }
353
+
347
354
return new GraphQLObjectType ( {
348
- name : type . name ,
355
+ name,
349
356
description : type . description ,
350
357
interfaces : ( ) => extendImplementedInterfaces ( type ) ,
351
358
fields : ( ) => extendFieldMap ( type ) ,
359
+ astNode : type . astNode ,
360
+ extensionASTNodes,
352
361
isTypeOf : type . isTypeOf ,
353
362
} ) ;
354
363
}
@@ -360,6 +369,7 @@ export function extendSchema(
360
369
name : type . name ,
361
370
description : type . description ,
362
371
fields : ( ) => extendFieldMap ( type ) ,
372
+ astNode : type . astNode ,
363
373
resolveType : type . resolveType ,
364
374
} ) ;
365
375
}
@@ -369,6 +379,7 @@ export function extendSchema(
369
379
name : type . name ,
370
380
description : type . description ,
371
381
types : type . getTypes ( ) . map ( getTypeFromDef ) ,
382
+ astNode : type . astNode ,
372
383
resolveType : type . resolveType ,
373
384
} ) ;
374
385
}
@@ -409,6 +420,7 @@ export function extendSchema(
409
420
deprecationReason : field . deprecationReason ,
410
421
type : extendFieldType ( field . type ) ,
411
422
args : keyMap ( field . args , arg => arg . name ) ,
423
+ astNode : field . astNode ,
412
424
resolve : field . resolve ,
413
425
} ;
414
426
} ) ;
@@ -430,6 +442,7 @@ export function extendSchema(
430
442
description : getDescription ( field ) ,
431
443
type : buildOutputFieldType ( field . type ) ,
432
444
args : buildInputValues ( field . arguments ) ,
445
+ astNode : field ,
433
446
deprecationReason : getDeprecationReason ( field . directives ) ,
434
447
} ;
435
448
} ) ;
@@ -467,6 +480,7 @@ export function extendSchema(
467
480
description : getDescription ( typeNode ) ,
468
481
interfaces : ( ) => buildImplementedInterfaces ( typeNode ) ,
469
482
fields : ( ) => buildFieldMap ( typeNode ) ,
483
+ astNode : typeNode ,
470
484
} ) ;
471
485
}
472
486
@@ -475,6 +489,7 @@ export function extendSchema(
475
489
name : typeNode . name . value ,
476
490
description : getDescription ( typeNode ) ,
477
491
fields : ( ) => buildFieldMap ( typeNode ) ,
492
+ astNode : typeNode ,
478
493
resolveType : cannotExecuteExtendedSchema ,
479
494
} ) ;
480
495
}
@@ -484,6 +499,7 @@ export function extendSchema(
484
499
name : typeNode . name . value ,
485
500
description : getDescription ( typeNode ) ,
486
501
types : typeNode . types . map ( getObjectTypeFromAST ) ,
502
+ astNode : typeNode ,
487
503
resolveType : cannotExecuteExtendedSchema ,
488
504
} ) ;
489
505
}
@@ -492,6 +508,7 @@ export function extendSchema(
492
508
return new GraphQLScalarType ( {
493
509
name : typeNode . name . value ,
494
510
description : getDescription ( typeNode ) ,
511
+ astNode : typeNode ,
495
512
serialize : id => id ,
496
513
// Note: validation calls the parse functions to determine if a
497
514
// literal value is correct. Returning null would cause use of custom
@@ -512,8 +529,10 @@ export function extendSchema(
512
529
enumValue => ( {
513
530
description : getDescription ( enumValue ) ,
514
531
deprecationReason : getDeprecationReason ( enumValue . directives ) ,
532
+ astNode : enumValue ,
515
533
} ) ,
516
534
) ,
535
+ astNode : typeNode ,
517
536
} ) ;
518
537
}
519
538
@@ -522,6 +541,7 @@ export function extendSchema(
522
541
name : typeNode . name . value ,
523
542
description : getDescription ( typeNode ) ,
524
543
fields : ( ) => buildInputValues ( typeNode . fields ) ,
544
+ astNode : typeNode ,
525
545
} ) ;
526
546
}
527
547
@@ -535,6 +555,7 @@ export function extendSchema(
535
555
) ,
536
556
args :
537
557
directiveNode . arguments && buildInputValues ( directiveNode . arguments ) ,
558
+ astNode : directiveNode ,
538
559
} ) ;
539
560
}
540
561
@@ -552,6 +573,7 @@ export function extendSchema(
552
573
description : getDescription ( field ) ,
553
574
args : buildInputValues ( field . arguments ) ,
554
575
deprecationReason : getDeprecationReason ( field . directives ) ,
576
+ astNode : field ,
555
577
} )
556
578
) ;
557
579
}
@@ -565,7 +587,8 @@ export function extendSchema(
565
587
return {
566
588
type,
567
589
description : getDescription ( value ) ,
568
- defaultValue : valueFromAST ( value . defaultValue , type )
590
+ defaultValue : valueFromAST ( value . defaultValue , type ) ,
591
+ astNode : value ,
569
592
} ;
570
593
}
571
594
) ;
0 commit comments