You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'Variable "$input" got invalid value { a: "abc", b: 123 }; Within OneOf Input Object Type "TestInputObject", exactly one field must be specified, and the value for that field must be non-null.',
160
+
'Variable "$input" got invalid value { a: "abc", b: 123 }; Within OneOf Input Object type "TestInputObject", exactly one field must be specified, and the value for that field must be non-null.',
'Variable "$input" got invalid value { a: "abc", b: null }; Within OneOf Input Object Type "TestInputObject", exactly one field must be specified, and the value for that field must be non-null.',
184
+
'Variable "$input" got invalid value { a: "abc", b: null }; Within OneOf Input Object type "TestInputObject", exactly one field must be specified, and the value for that field must be non-null.',
'Variable "$input" got invalid value { a: null, b: null }; Within OneOf Input Object Type "TestInputObject", exactly one field must be specified, and the value for that field must be non-null.',
208
+
'Variable "$input" got invalid value { a: null, b: null }; Within OneOf Input Object type "TestInputObject", exactly one field must be specified, and the value for that field must be non-null.',
'Argument "input" of type "TestOneOfInputObject" has invalid value { a: "abc", b: null }.',
1208
+
path: ['fieldWithOneOfObjectInput'],
1209
+
locations: [{line: 3,column: 42}],
1210
+
},
1211
+
],
1212
+
});
1213
+
});
1214
+
1215
+
it('allows a variable for the entire OneOf Object with a single value',()=>{
1216
+
constresult=executeQuery(
1217
+
`
1218
+
query ($input: TestOneOfInputObject) {
1219
+
fieldWithOneOfObjectInput(input: $input)
1220
+
}
1221
+
`,
1222
+
{input: {a: 'abc'}},
1223
+
);
1224
+
1225
+
expectJSON(result).toDeepEqual({
1226
+
data: {
1227
+
fieldWithOneOfObjectInput: '{ a: "abc" }',
1228
+
},
1229
+
});
1230
+
});
1231
+
1232
+
it('allows a variable for the entire OneOf Object with a single defined value',()=>{
1233
+
constresult=executeQuery(
1234
+
`
1235
+
query ($input: TestOneOfInputObject) {
1236
+
fieldWithOneOfObjectInput(input: $input)
1237
+
}
1238
+
`,
1239
+
{input: {a: 'abc',b: undefined}},
1240
+
);
1241
+
1242
+
expectJSON(result).toDeepEqual({
1243
+
data: {
1244
+
fieldWithOneOfObjectInput: '{ a: "abc" }',
1245
+
},
1246
+
});
1247
+
});
1248
+
1249
+
it('errors with variable with no value',()=>{
1250
+
constresult=executeQuery(
1251
+
`
1252
+
query ($input: TestOneOfInputObject) {
1253
+
fieldWithOneOfObjectInput(input: $input)
1254
+
}
1255
+
`,
1256
+
{input: {}},
1257
+
);
1258
+
1259
+
expectJSON(result).toDeepEqual({
1260
+
errors: [
1261
+
{
1262
+
message:
1263
+
'Variable "$input" got invalid value {}; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
1264
+
locations: [{line: 2,column: 16}],
1265
+
},
1266
+
],
1267
+
});
1268
+
});
1269
+
1270
+
it('errors with variable with multiple values',()=>{
1271
+
constresult=executeQuery(
1272
+
`
1273
+
query ($input: TestOneOfInputObject) {
1274
+
fieldWithOneOfObjectInput(input: $input)
1275
+
}
1276
+
`,
1277
+
{input: {a: 'abc',b: 123}},
1278
+
);
1279
+
1280
+
expectJSON(result).toDeepEqual({
1281
+
errors: [
1282
+
{
1283
+
message:
1284
+
'Variable "$input" got invalid value { a: "abc", b: 123 }; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
1285
+
locations: [{line: 2,column: 16}],
1286
+
},
1287
+
],
1288
+
});
1289
+
});
1290
+
1291
+
it('errors with variable with single null value',()=>{
1292
+
constresult=executeQuery(
1293
+
`
1294
+
query ($input: TestOneOfInputObject) {
1295
+
fieldWithOneOfObjectInput(input: $input)
1296
+
}
1297
+
`,
1298
+
{input: {a: null}},
1299
+
);
1300
+
1301
+
expectJSON(result).toDeepEqual({
1302
+
errors: [
1303
+
{
1304
+
message:
1305
+
'Variable "$input" got invalid value null at "input.a"; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
1306
+
locations: [{line: 2,column: 16}],
1307
+
},
1308
+
],
1309
+
});
1310
+
});
1311
+
1312
+
it('errors with variable with multiple values, only one non-null',()=>{
1313
+
constresult=executeQuery(
1314
+
`
1315
+
query ($input: TestOneOfInputObject) {
1316
+
fieldWithOneOfObjectInput(input: $input)
1317
+
}
1318
+
`,
1319
+
{input: {a: 'abc',b: null}},
1320
+
);
1321
+
1322
+
expectJSON(result).toDeepEqual({
1323
+
errors: [
1324
+
{
1325
+
message:
1326
+
'Variable "$input" got invalid value { a: "abc", b: null }; Within OneOf Input Object type "TestOneOfInputObject", exactly one field must be specified, and the value for that field must be non-null.',
1327
+
locations: [{line: 2,column: 16}],
1328
+
},
1329
+
],
1330
+
});
1331
+
});
1332
+
1117
1333
describe('getVariableValues: limit maximum number of coercion errors',()=>{
0 commit comments