@@ -272,6 +272,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
272
272
null ,
273
273
types ,
274
274
directives ,
275
+ astNode : schemaDef ,
275
276
} );
276
277
277
278
function getDirective(
@@ -284,6 +285,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
284
285
node => ( ( node . value : any ) : DirectiveLocationEnum )
285
286
) ,
286
287
args : directiveNode . arguments && makeInputValues ( directiveNode . arguments ) ,
288
+ astNode : directiveNode ,
287
289
} ) ;
288
290
}
289
291
@@ -368,6 +370,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
368
370
description : getDescription ( def ) ,
369
371
fields : ( ) => makeFieldDefMap ( def ) ,
370
372
interfaces : ( ) => makeImplementedInterfaces ( def ) ,
373
+ astNode : def ,
371
374
} ) ;
372
375
}
373
376
@@ -381,7 +384,8 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
381
384
type : produceOutputType ( field . type ) ,
382
385
description : getDescription ( field ) ,
383
386
args : makeInputValues ( field . arguments ) ,
384
- deprecationReason : getDeprecationReason ( field . directives )
387
+ deprecationReason : getDeprecationReason ( field . directives ) ,
388
+ astNode : field ,
385
389
} )
386
390
) ;
387
391
}
@@ -400,7 +404,8 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
400
404
return {
401
405
type,
402
406
description : getDescription ( value ) ,
403
- defaultValue : valueFromAST ( value . defaultValue , type )
407
+ defaultValue : valueFromAST ( value . defaultValue , type ) ,
408
+ astNode : value ,
404
409
} ;
405
410
}
406
411
) ;
@@ -412,6 +417,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
412
417
name : typeName ,
413
418
description : getDescription ( def ) ,
414
419
fields : ( ) => makeFieldDefMap ( def ) ,
420
+ astNode : def ,
415
421
resolveType : cannotExecuteSchema ,
416
422
} ) ;
417
423
}
@@ -425,9 +431,11 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
425
431
enumValue => enumValue . name . value ,
426
432
enumValue => ( {
427
433
description : getDescription ( enumValue ) ,
428
- deprecationReason : getDeprecationReason ( enumValue . directives )
434
+ deprecationReason : getDeprecationReason ( enumValue . directives ) ,
435
+ astNode : enumValue
429
436
} )
430
437
) ,
438
+ astNode : def ,
431
439
} ) ;
432
440
433
441
return enumType ;
@@ -439,13 +447,15 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
439
447
description : getDescription ( def ) ,
440
448
types : def . types . map ( t => produceObjectType ( t ) ) ,
441
449
resolveType : cannotExecuteSchema ,
450
+ astNode : def ,
442
451
} ) ;
443
452
}
444
453
445
454
function makeScalarDef(def: ScalarTypeDefinitionNode) {
446
455
return new GraphQLScalarType ( {
447
456
name : def . name . value ,
448
457
description : getDescription ( def ) ,
458
+ astNode : def ,
449
459
serialize : ( ) => null ,
450
460
// Note: validation calls the parse functions to determine if a
451
461
// literal value is correct. Returning null would cause use of custom
@@ -461,6 +471,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
461
471
name : def . name . value ,
462
472
description : getDescription ( def ) ,
463
473
fields : ( ) => makeInputValues ( def . fields ) ,
474
+ astNode : def ,
464
475
} ) ;
465
476
}
466
477
}
0 commit comments