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
My previous proposal only addressed pure OneOf cycles, and failed to
handle other invalid cycles, like mixed OneOf/non-Oneof cycles:
```
input A @OneOf { b:B }
input B { a:A! }
```
This trues up the implementation with the proposed spec changes, which
consolidates input cycle detection under one algorithm:
InputObjectCanBeProvidedAFiniteValue
Copy file name to clipboardExpand all lines: src/type/__tests__/validation-test.ts
+264-8Lines changed: 264 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -924,7 +924,7 @@ describe('Type System: Input Objects must have fields', () => {
924
924
expectJSON(validateSchema(schema)).toDeepEqual([
925
925
{
926
926
message:
927
-
'Invalid circular reference. The Input Object SomeInputObject references itself in the non-null field SomeInputObject.nonNullSelf.',
927
+
'Input Object SomeInputObject references itself via the required fields: SomeInputObject.nonNullSelf.',
928
928
locations: [{line: 7,column: 9}],
929
929
},
930
930
]);
@@ -952,13 +952,31 @@ describe('Type System: Input Objects must have fields', () => {
952
952
expectJSON(validateSchema(schema)).toDeepEqual([
953
953
{
954
954
message:
955
-
'Invalid circular reference. The Input Object SomeInputObject references itself via the non-null fields: SomeInputObject.startLoop, AnotherInputObject.nextInLoop, YetAnotherInputObject.closeLoop.',
955
+
'Input Object SomeInputObject references itself via the required fields: SomeInputObject.startLoop, AnotherInputObject.nextInLoop, YetAnotherInputObject.closeLoop.',
956
956
locations: [
957
957
{line: 7,column: 9},
958
958
{line: 11,column: 9},
959
959
{line: 15,column: 9},
960
960
],
961
961
},
962
+
{
963
+
message:
964
+
'Input Object AnotherInputObject references itself via the required fields: AnotherInputObject.nextInLoop, YetAnotherInputObject.closeLoop, SomeInputObject.startLoop.',
965
+
locations: [
966
+
{line: 11,column: 9},
967
+
{line: 15,column: 9},
968
+
{line: 7,column: 9},
969
+
],
970
+
},
971
+
{
972
+
message:
973
+
'Input Object YetAnotherInputObject references itself via the required fields: YetAnotherInputObject.closeLoop, SomeInputObject.startLoop, AnotherInputObject.nextInLoop.',
974
+
locations: [
975
+
{line: 15,column: 9},
976
+
{line: 7,column: 9},
977
+
{line: 11,column: 9},
978
+
],
979
+
},
962
980
]);
963
981
});
964
982
@@ -986,24 +1004,28 @@ describe('Type System: Input Objects must have fields', () => {
986
1004
expectJSON(validateSchema(schema)).toDeepEqual([
987
1005
{
988
1006
message:
989
-
'Invalid circular reference. The Input Object SomeInputObject references itself via the non-null fields: SomeInputObject.startLoop, AnotherInputObject.closeLoop.',
1007
+
'Input Object SomeInputObject references itself via the required fields: SomeInputObject.startLoop, AnotherInputObject.closeLoop.',
990
1008
locations: [
991
1009
{line: 7,column: 9},
992
1010
{line: 11,column: 9},
993
1011
],
994
1012
},
995
1013
{
996
1014
message:
997
-
'Invalid circular reference. The Input Object AnotherInputObject references itself via the non-null fields: AnotherInputObject.startSecondLoop, YetAnotherInputObject.closeSecondLoop.',
1015
+
'Input Object AnotherInputObject references itself via the required fields: AnotherInputObject.closeLoop, SomeInputObject.startLoop.',
998
1016
locations: [
999
-
{line: 12,column: 9},
1000
-
{line: 16,column: 9},
1017
+
{line: 11,column: 9},
1018
+
{line: 7,column: 9},
1001
1019
],
1002
1020
},
1003
1021
{
1004
1022
message:
1005
-
'Invalid circular reference. The Input Object YetAnotherInputObject references itself in the non-null field YetAnotherInputObject.nonNullSelf.',
1006
-
locations: [{line: 17,column: 9}],
1023
+
'Input Object YetAnotherInputObject references itself via the required fields: YetAnotherInputObject.closeSecondLoop, AnotherInputObject.closeLoop, SomeInputObject.startLoop.',
1024
+
locations: [
1025
+
{line: 16,column: 9},
1026
+
{line: 11,column: 9},
1027
+
{line: 7,column: 9},
1028
+
],
1007
1029
},
1008
1030
]);
1009
1031
});
@@ -2409,6 +2431,240 @@ describe('Type System: OneOf Input Object fields must be nullable', () => {
2409
2431
});
2410
2432
});
2411
2433
2434
+
describe('Type System: Input Objects must be provided a finite value',()=>{
2435
+
it('accepts a OneOf Input Object with a scalar field',()=>{
0 commit comments