@@ -240,6 +240,7 @@ export function extendSchema(
240
240
subscription : subscriptionType ,
241
241
types,
242
242
directives : getMergedDirectives ( ) ,
243
+ astNode : schema . astNode ,
243
244
} ) ;
244
245
245
246
// Below are functions used for producing this schema that have closed over
@@ -332,11 +333,19 @@ export function extendSchema(
332
333
}
333
334
334
335
function extendObjectType ( type : GraphQLObjectType ) : GraphQLObjectType {
336
+ const name = type . name ;
337
+ let extensionASTNodes = type . extensionASTNodes ;
338
+ if ( typeExtensionsMap [ name ] ) {
339
+ extensionASTNodes = extensionASTNodes . concat ( typeExtensionsMap [ name ] ) ;
340
+ }
341
+
335
342
return new GraphQLObjectType ( {
336
- name : type . name ,
343
+ name,
337
344
description : type . description ,
338
345
interfaces : ( ) => extendImplementedInterfaces ( type ) ,
339
346
fields : ( ) => extendFieldMap ( type ) ,
347
+ astNode : type . astNode ,
348
+ extensionASTNodes,
340
349
isTypeOf : type . isTypeOf ,
341
350
} ) ;
342
351
}
@@ -348,6 +357,7 @@ export function extendSchema(
348
357
name : type . name ,
349
358
description : type . description ,
350
359
fields : ( ) => extendFieldMap ( type ) ,
360
+ astNode : type . astNode ,
351
361
resolveType : type . resolveType ,
352
362
} ) ;
353
363
}
@@ -357,6 +367,7 @@ export function extendSchema(
357
367
name : type . name ,
358
368
description : type . description ,
359
369
types : type . getTypes ( ) . map ( getTypeFromDef ) ,
370
+ astNode : type . astNode ,
360
371
resolveType : type . resolveType ,
361
372
} ) ;
362
373
}
@@ -397,6 +408,7 @@ export function extendSchema(
397
408
deprecationReason : field . deprecationReason ,
398
409
type : extendFieldType ( field . type ) ,
399
410
args : keyMap ( field . args , arg => arg . name ) ,
411
+ astNode : field . astNode ,
400
412
resolve : field . resolve ,
401
413
} ;
402
414
} ) ;
@@ -419,6 +431,7 @@ export function extendSchema(
419
431
type : buildOutputFieldType ( field . type ) ,
420
432
args : buildInputValues ( field . arguments ) ,
421
433
deprecationReason : getDeprecationReason ( field ) ,
434
+ astNode : field ,
422
435
} ;
423
436
} ) ;
424
437
} ) ;
@@ -456,6 +469,7 @@ export function extendSchema(
456
469
description : getDescription ( typeNode ) ,
457
470
interfaces : ( ) => buildImplementedInterfaces ( typeNode ) ,
458
471
fields : ( ) => buildFieldMap ( typeNode ) ,
472
+ astNode : typeNode ,
459
473
} ) ;
460
474
}
461
475
@@ -464,6 +478,7 @@ export function extendSchema(
464
478
name : typeNode . name . value ,
465
479
description : getDescription ( typeNode ) ,
466
480
fields : ( ) => buildFieldMap ( typeNode ) ,
481
+ astNode : typeNode ,
467
482
resolveType : cannotExecuteExtendedSchema ,
468
483
} ) ;
469
484
}
@@ -473,6 +488,7 @@ export function extendSchema(
473
488
name : typeNode . name . value ,
474
489
description : getDescription ( typeNode ) ,
475
490
types : typeNode . types . map ( getObjectTypeFromAST ) ,
491
+ astNode : typeNode ,
476
492
resolveType : cannotExecuteExtendedSchema ,
477
493
} ) ;
478
494
}
@@ -481,6 +497,7 @@ export function extendSchema(
481
497
return new GraphQLScalarType ( {
482
498
name : typeNode . name . value ,
483
499
description : getDescription ( typeNode ) ,
500
+ astNode : typeNode ,
484
501
serialize : id => id ,
485
502
// Note: validation calls the parse functions to determine if a
486
503
// literal value is correct. Returning null would cause use of custom
@@ -501,8 +518,10 @@ export function extendSchema(
501
518
enumValue => ( {
502
519
description : getDescription ( enumValue ) ,
503
520
deprecationReason : getDeprecationReason ( enumValue ) ,
521
+ astNode : enumValue ,
504
522
} ) ,
505
523
) ,
524
+ astNode : typeNode ,
506
525
} ) ;
507
526
}
508
527
@@ -511,6 +530,7 @@ export function extendSchema(
511
530
name : typeNode . name . value ,
512
531
description : getDescription ( typeNode ) ,
513
532
fields : ( ) => buildInputValues ( typeNode . fields ) ,
533
+ astNode : typeNode ,
514
534
} ) ;
515
535
}
516
536
@@ -524,6 +544,7 @@ export function extendSchema(
524
544
) ,
525
545
args :
526
546
directiveNode . arguments && buildInputValues ( directiveNode . arguments ) ,
547
+ astNode : directiveNode ,
527
548
} ) ;
528
549
}
529
550
@@ -541,6 +562,7 @@ export function extendSchema(
541
562
description : getDescription ( field ) ,
542
563
args : buildInputValues ( field . arguments ) ,
543
564
deprecationReason : getDeprecationReason ( field ) ,
565
+ astNode : field ,
544
566
} )
545
567
) ;
546
568
}
@@ -554,7 +576,8 @@ export function extendSchema(
554
576
return {
555
577
type,
556
578
description : getDescription ( value ) ,
557
- defaultValue : valueFromAST ( value . defaultValue , type )
579
+ defaultValue : valueFromAST ( value . defaultValue , type ) ,
580
+ astNode : value ,
558
581
} ;
559
582
}
560
583
) ;
0 commit comments