Skip to content

Commit 933a5fe

Browse files
committed
npm test passing
1 parent 1c82768 commit 933a5fe

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

src/validation/__tests__/OverlappingFieldsCanBeMergedRule-test.ts

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,139 @@ describe('Validate: Overlapping fields can be merged', () => {
941941
);
942942
});
943943

944+
it('allows non-conflicting overlapping required statuses', () => {
945+
expectValidationErrorsWithSchema(
946+
schema,
947+
OverlappingFieldsCanBeMergedRule,
948+
`
949+
{
950+
someBox {
951+
... on IntBox {
952+
scalar: unrelatedField!
953+
}
954+
... on StringBox {
955+
scalar!
956+
}
957+
}
958+
}
959+
`,
960+
{
961+
experimentalClientControlledNullability: true,
962+
},
963+
);
964+
965+
expectValidationErrorsWithSchema(
966+
schema,
967+
OverlappingFieldsCanBeMergedRule,
968+
`
969+
{
970+
someBox {
971+
... on IntBox {
972+
scalar: unrelatedField?
973+
}
974+
... on StringBox {
975+
scalar?
976+
}
977+
}
978+
}
979+
`,
980+
{
981+
experimentalClientControlledNullability: true,
982+
},
983+
);
984+
// TODO: need one with list designators
985+
});
986+
987+
it('disallows conflicting overlapping required statuses', () => {
988+
expectValidationErrorsWithSchema(
989+
schema,
990+
OverlappingFieldsCanBeMergedRule,
991+
`
992+
{
993+
someBox {
994+
... on IntBox {
995+
scalar: unrelatedField!
996+
}
997+
... on StringBox {
998+
scalar
999+
}
1000+
}
1001+
}
1002+
`,
1003+
{
1004+
experimentalClientControlledNullability: true,
1005+
},
1006+
).toDeepEqual([
1007+
{
1008+
message:
1009+
'Fields "scalar" conflict because they have conflicting nullability designators "!" and "". Use different aliases on the fields to fetch both if this was intentional.',
1010+
locations: [
1011+
{ line: 5, column: 17 },
1012+
{ line: 8, column: 17 },
1013+
],
1014+
},
1015+
]);
1016+
1017+
expectValidationErrorsWithSchema(
1018+
schema,
1019+
OverlappingFieldsCanBeMergedRule,
1020+
`
1021+
{
1022+
someBox {
1023+
... on IntBox {
1024+
scalar: unrelatedField!
1025+
}
1026+
... on StringBox {
1027+
scalar?
1028+
}
1029+
}
1030+
}
1031+
`,
1032+
{
1033+
experimentalClientControlledNullability: true,
1034+
},
1035+
).toDeepEqual([
1036+
{
1037+
message:
1038+
'Fields "scalar" conflict because they have conflicting nullability designators "!" and "?". Use different aliases on the fields to fetch both if this was intentional.',
1039+
locations: [
1040+
{ line: 5, column: 17 },
1041+
{ line: 8, column: 17 },
1042+
],
1043+
},
1044+
]);
1045+
1046+
expectValidationErrorsWithSchema(
1047+
schema,
1048+
OverlappingFieldsCanBeMergedRule,
1049+
`
1050+
{
1051+
someBox {
1052+
... on IntBox {
1053+
scalar: unrelatedField
1054+
}
1055+
... on StringBox {
1056+
scalar?
1057+
}
1058+
}
1059+
}
1060+
`,
1061+
{
1062+
experimentalClientControlledNullability: true,
1063+
},
1064+
).toDeepEqual([
1065+
{
1066+
message:
1067+
'Fields "scalar" conflict because they have conflicting nullability designators "" and "?". Use different aliases on the fields to fetch both if this was intentional.',
1068+
locations: [
1069+
{ line: 5, column: 17 },
1070+
{ line: 8, column: 17 },
1071+
],
1072+
},
1073+
]);
1074+
// TODO: need one with list designators
1075+
});
1076+
9441077
it('same wrapped scalar return types', () => {
9451078
expectValidWithSchema(
9461079
schema,

0 commit comments

Comments
 (0)