@@ -426,6 +426,72 @@ describe('transform object fields', () => {
426
426
} ) ;
427
427
} ) ;
428
428
429
+ describe ( 'optional arguments' , ( ) => {
430
+ const schema = makeExecutableSchema ( {
431
+ typeDefs : `
432
+ enum Arg {
433
+ possibleArg
434
+ }
435
+ type Query {
436
+ test(arg: Arg): Boolean
437
+ }
438
+ ` ,
439
+ resolvers : {
440
+ Query : {
441
+ test : ( _root , args , _context ) => args . arg === undefined
442
+ }
443
+ }
444
+ } ) ;
445
+
446
+ const stitchedSchema = stitchSchemas ( {
447
+ schemas : [ schema ] ,
448
+ } ) ;
449
+
450
+ it ( 'work with schema stitching' , async ( ) => {
451
+ const query = `
452
+ {
453
+ test
454
+ }
455
+ ` ;
456
+
457
+ const originalResult = await graphql ( schema , query ) ;
458
+ expect ( originalResult . data . test ) . toEqual ( true ) ;
459
+
460
+ const stitchedResult = await graphql ( stitchedSchema , query ) ;
461
+ expect ( stitchedResult . data . test ) . toEqual ( true ) ;
462
+ } ) ;
463
+
464
+ it ( 'work with schema stitching when using variables' , async ( ) => {
465
+ const query = `
466
+ query test($arg: Arg) {
467
+ test(arg: $arg)
468
+ }
469
+ ` ;
470
+
471
+ const originalResult = await graphql ( schema , query ) ;
472
+ expect ( originalResult . data . test ) . toEqual ( true ) ;
473
+
474
+ const stitchedResult = await graphql ( stitchedSchema , query ) ;
475
+ expect ( stitchedResult . data . test ) . toEqual ( true ) ;
476
+ } ) ;
477
+
478
+ // See https://github.com/graphql/graphql-js/issues/2533
479
+ it ( 'may not work as expected when explicitly passing in an undefined value' , async ( ) => {
480
+ const query = `
481
+ query test($arg: Arg) {
482
+ test(arg: $arg)
483
+ }
484
+ ` ;
485
+
486
+ const originalResult = await graphql ( schema , query , { } , { } , { arg : undefined } ) ;
487
+ expect ( originalResult . data . test ) . toEqual ( false ) ;
488
+
489
+ const stitchedResult = await graphql ( stitchedSchema , query , { } , { } , { arg : undefined } ) ;
490
+ expect ( stitchedResult . data . test ) . toEqual ( false ) ;
491
+ } ) ;
492
+ } ) ;
493
+
494
+
429
495
describe ( 'default values' , ( ) => {
430
496
test ( 'should work to add a default value even when renaming root fields' , async ( ) => {
431
497
const transformedPropertySchema = transformSchema ( propertySchema , [
0 commit comments