@@ -357,4 +357,65 @@ describe('Validate: Variables are in allowed positions', () => {
357357 }` ) ;
358358 } ) ;
359359 } ) ;
360+
361+ describe ( 'Fragment arguments are validated' , ( ) => {
362+ it ( 'Boolean => Boolean' , ( ) => {
363+ expectValid ( `
364+ query Query($booleanArg: Boolean)
365+ {
366+ complicatedArgs {
367+ ...A(b: $booleanArg)
368+ }
369+ }
370+ fragment A($b: Boolean) on ComplicatedArgs {
371+ booleanArgField(booleanArg: $b)
372+ }
373+ ` ) ;
374+ } ) ;
375+
376+ it ( 'Boolean => Boolean!' , ( ) => {
377+ expectErrors ( `
378+ query Query($fb: Boolean)
379+ {
380+ complicatedArgs {
381+ ...A(b: $fb)
382+ }
383+ }
384+ fragment A($b: Boolean!) on ComplicatedArgs {
385+ booleanArgField(booleanArg: $b)
386+ }
387+ ` ) . toDeepEqual ( [
388+ {
389+ message :
390+ 'Variable "$booleanArg" of type "Boolean" used in position expecting type "Boolean!".' ,
391+ locations : [
392+ { line : 2 , column : 21 } ,
393+ { line : 4 , column : 47 } ,
394+ ] ,
395+ } ,
396+ ] ) ;
397+ } ) ;
398+
399+ it ( 'Int => Int! fails when variable provides null default value' , ( ) => {
400+ expectErrors ( `
401+ query Query($intVar: Int = null) {
402+ complicatedArgs {
403+ ...A(i: $intVar)
404+ }
405+ }
406+ fragment A($i: Int!) on ComplicatedArgs {
407+ nonNullIntArgField(nonNullIntArg: $i)
408+ }
409+ ` ) . toDeepEqual ( [
410+ {
411+ message :
412+ 'Variable "$intVar" of type "Int" used in position expecting type "Int!".' ,
413+ locations : [
414+ { line : 2 , column : 21 } ,
415+ { line : 4 , column : 47 } ,
416+ ] ,
417+ } ,
418+ ] ) ;
419+ } ) ;
420+ } ) ;
360421} ) ;
0 commit comments