@@ -263,6 +263,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
263
263
null ,
264
264
types ,
265
265
directives ,
266
+ astNode : schemaDef ,
266
267
} );
267
268
268
269
function getDirective(
@@ -275,6 +276,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
275
276
node => ( ( node . value : any ) : DirectiveLocationEnum )
276
277
) ,
277
278
args : directiveNode . arguments && makeInputValues ( directiveNode . arguments ) ,
279
+ astNode : directiveNode ,
278
280
} ) ;
279
281
}
280
282
@@ -359,6 +361,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
359
361
description : getDescription ( def ) ,
360
362
fields : ( ) => makeFieldDefMap ( def ) ,
361
363
interfaces : ( ) => makeImplementedInterfaces ( def ) ,
364
+ astNode : def ,
362
365
} ) ;
363
366
}
364
367
@@ -372,7 +375,8 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
372
375
type : produceOutputType ( field . type ) ,
373
376
description : getDescription ( field ) ,
374
377
args : makeInputValues ( field . arguments ) ,
375
- deprecationReason : getDeprecationReason ( field )
378
+ deprecationReason : getDeprecationReason ( field ) ,
379
+ astNode : field ,
376
380
} )
377
381
) ;
378
382
}
@@ -391,7 +395,8 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
391
395
return {
392
396
type,
393
397
description : getDescription ( value ) ,
394
- defaultValue : valueFromAST ( value . defaultValue , type )
398
+ defaultValue : valueFromAST ( value . defaultValue , type ) ,
399
+ astNode : value ,
395
400
} ;
396
401
}
397
402
) ;
@@ -403,6 +408,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
403
408
name : typeName ,
404
409
description : getDescription ( def ) ,
405
410
fields : ( ) => makeFieldDefMap ( def ) ,
411
+ astNode : def ,
406
412
resolveType : cannotExecuteSchema ,
407
413
} ) ;
408
414
}
@@ -416,9 +422,11 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
416
422
enumValue => enumValue . name . value ,
417
423
enumValue => ( {
418
424
description : getDescription ( enumValue ) ,
419
- deprecationReason : getDeprecationReason ( enumValue )
425
+ deprecationReason : getDeprecationReason ( enumValue ) ,
426
+ astNode : enumValue ,
420
427
} )
421
428
) ,
429
+ astNode : def ,
422
430
} ) ;
423
431
424
432
return enumType ;
@@ -430,13 +438,15 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
430
438
description : getDescription ( def ) ,
431
439
types : def . types . map ( t => produceObjectType ( t ) ) ,
432
440
resolveType : cannotExecuteSchema ,
441
+ astNode : def ,
433
442
} ) ;
434
443
}
435
444
436
445
function makeScalarDef(def: ScalarTypeDefinitionNode) {
437
446
return new GraphQLScalarType ( {
438
447
name : def . name . value ,
439
448
description : getDescription ( def ) ,
449
+ astNode : def ,
440
450
serialize : ( ) => null ,
441
451
// Note: validation calls the parse functions to determine if a
442
452
// literal value is correct. Returning null would cause use of custom
@@ -452,6 +462,7 @@ export function buildASTSchema(ast: DocumentNode): GraphQLSchema {
452
462
name : def . name . value ,
453
463
description : getDescription ( def ) ,
454
464
fields : ( ) => makeInputValues ( def . fields ) ,
465
+ astNode : def ,
455
466
} ) ;
456
467
}
457
468
}
0 commit comments