@@ -1014,6 +1014,23 @@ describe('Execute: Handles inputs', () => {
10141014 } ) ;
10151015
10161016 describe ( 'using fragment arguments' , ( ) => {
1017+ it ( 'when there are no fragment arguments' , ( ) => {
1018+ const result = executeQuery ( `
1019+ query {
1020+ ...a
1021+ }
1022+
1023+ fragment a on TestType {
1024+ fieldWithNonNullableStringInput(input: "A")
1025+ }
1026+ ` ) ;
1027+ expect ( result ) . to . deep . equal ( {
1028+ data : {
1029+ fieldWithNonNullableStringInput : '"A"' ,
1030+ } ,
1031+ } ) ;
1032+ } ) ;
1033+
10171034 it ( 'when a value is required and provided' , ( ) => {
10181035 const result = executeQueryWithFragmentArguments ( `
10191036 query {
@@ -1031,6 +1048,33 @@ describe('Execute: Handles inputs', () => {
10311048 } ) ;
10321049 } ) ;
10331050
1051+ it ( 'when a value is required and not provided' , ( ) => {
1052+ const result = executeQueryWithFragmentArguments ( `
1053+ query {
1054+ ...a
1055+ }
1056+
1057+ fragment a($value: String!) on TestType {
1058+ fieldWithNullableStringInput(input: $value)
1059+ }
1060+ ` ) ;
1061+ expect ( result ) . to . deep . equal ( {
1062+ data : {
1063+ fieldWithNullableStringInput : null ,
1064+ } ,
1065+ errors : [
1066+ {
1067+ message :
1068+ 'Fragment argument "$value" on fragment "a" is required but not provided.' ,
1069+ locations : [
1070+ { line : 3 , column : 11 } ,
1071+ { line : 6 , column : 20 } ,
1072+ ] ,
1073+ } ,
1074+ ] ,
1075+ } ) ;
1076+ } ) ;
1077+
10341078 it ( 'when the definition has a default and is provided' , ( ) => {
10351079 const result = executeQueryWithFragmentArguments ( `
10361080 query {
@@ -1065,6 +1109,33 @@ describe('Execute: Handles inputs', () => {
10651109 } ) ;
10661110 } ) ;
10671111
1112+ it ( 'when the definition has a non-nullable default and is provided null' , ( ) => {
1113+ const result = executeQueryWithFragmentArguments ( `
1114+ query {
1115+ ...a(value: null)
1116+ }
1117+
1118+ fragment a($value: String! = "B") on TestType {
1119+ fieldWithNullableStringInput(input: $value)
1120+ }
1121+ ` ) ;
1122+ expect ( result ) . to . deep . equal ( {
1123+ data : {
1124+ fieldWithNullableStringInput : 'null' ,
1125+ } ,
1126+ errors : [
1127+ {
1128+ message :
1129+ 'Fragment argument "$value" on fragment "a" is non-null, but null was provided.' ,
1130+ locations : [
1131+ { line : 3 , column : 16 } ,
1132+ { line : 6 , column : 20 } ,
1133+ ] ,
1134+ } ,
1135+ ] ,
1136+ } ) ;
1137+ } ) ;
1138+
10681139 it ( 'when the definition has no default and is not provided' , ( ) => {
10691140 const result = executeQueryWithFragmentArguments ( `
10701141 query {
@@ -1082,6 +1153,44 @@ describe('Execute: Handles inputs', () => {
10821153 } ,
10831154 } ) ;
10841155 } ) ;
1156+
1157+ it ( 'when the argument variable is nested in a complex type' , ( ) => {
1158+ const result = executeQueryWithFragmentArguments ( `
1159+ query {
1160+ ...a(value: "C")
1161+ }
1162+
1163+ fragment a($value: String) on TestType {
1164+ list(input: ["A", "B", $value, "D"])
1165+ }
1166+ ` ) ;
1167+ expect ( result ) . to . deep . equal ( {
1168+ data : {
1169+ list : '["A", "B", "C", "D"]' ,
1170+ } ,
1171+ } ) ;
1172+ } ) ;
1173+
1174+ it ( 'when argument variables are used recursively' , ( ) => {
1175+ const result = executeQueryWithFragmentArguments ( `
1176+ query {
1177+ ...a(aValue: "C")
1178+ }
1179+
1180+ fragment a($aValue: String) on TestType {
1181+ ...b(bValue: $aValue)
1182+ }
1183+
1184+ fragment b($bValue: String) on TestType {
1185+ list(input: ["A", "B", $bValue, "D"])
1186+ }
1187+ ` ) ;
1188+ expect ( result ) . to . deep . equal ( {
1189+ data : {
1190+ list : '["A", "B", "C", "D"]' ,
1191+ } ,
1192+ } ) ;
1193+ } ) ;
10851194 } ) ;
10861195
10871196 describe ( 'getVariableValues: limit maximum number of coercion errors' , ( ) => {
0 commit comments