Skip to content

Commit e19360b

Browse files
committed
npm test passing
1 parent 7036ee7 commit e19360b

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
@@ -1049,6 +1049,139 @@ describe('Validate: Overlapping fields can be merged', () => {
10491049
);
10501050
});
10511051

1052+
it('allows non-conflicting overlapping required statuses', () => {
1053+
expectValidationErrorsWithSchema(
1054+
schema,
1055+
OverlappingFieldsCanBeMergedRule,
1056+
`
1057+
{
1058+
someBox {
1059+
... on IntBox {
1060+
scalar: unrelatedField!
1061+
}
1062+
... on StringBox {
1063+
scalar!
1064+
}
1065+
}
1066+
}
1067+
`,
1068+
{
1069+
experimentalClientControlledNullability: true,
1070+
},
1071+
);
1072+
1073+
expectValidationErrorsWithSchema(
1074+
schema,
1075+
OverlappingFieldsCanBeMergedRule,
1076+
`
1077+
{
1078+
someBox {
1079+
... on IntBox {
1080+
scalar: unrelatedField?
1081+
}
1082+
... on StringBox {
1083+
scalar?
1084+
}
1085+
}
1086+
}
1087+
`,
1088+
{
1089+
experimentalClientControlledNullability: true,
1090+
},
1091+
);
1092+
// TODO: need one with list designators
1093+
});
1094+
1095+
it('disallows conflicting overlapping required statuses', () => {
1096+
expectValidationErrorsWithSchema(
1097+
schema,
1098+
OverlappingFieldsCanBeMergedRule,
1099+
`
1100+
{
1101+
someBox {
1102+
... on IntBox {
1103+
scalar: unrelatedField!
1104+
}
1105+
... on StringBox {
1106+
scalar
1107+
}
1108+
}
1109+
}
1110+
`,
1111+
{
1112+
experimentalClientControlledNullability: true,
1113+
},
1114+
).toDeepEqual([
1115+
{
1116+
message:
1117+
'Fields "scalar" conflict because they have conflicting nullability designators "!" and "". Use different aliases on the fields to fetch both if this was intentional.',
1118+
locations: [
1119+
{ line: 5, column: 17 },
1120+
{ line: 8, column: 17 },
1121+
],
1122+
},
1123+
]);
1124+
1125+
expectValidationErrorsWithSchema(
1126+
schema,
1127+
OverlappingFieldsCanBeMergedRule,
1128+
`
1129+
{
1130+
someBox {
1131+
... on IntBox {
1132+
scalar: unrelatedField!
1133+
}
1134+
... on StringBox {
1135+
scalar?
1136+
}
1137+
}
1138+
}
1139+
`,
1140+
{
1141+
experimentalClientControlledNullability: true,
1142+
},
1143+
).toDeepEqual([
1144+
{
1145+
message:
1146+
'Fields "scalar" conflict because they have conflicting nullability designators "!" and "?". Use different aliases on the fields to fetch both if this was intentional.',
1147+
locations: [
1148+
{ line: 5, column: 17 },
1149+
{ line: 8, column: 17 },
1150+
],
1151+
},
1152+
]);
1153+
1154+
expectValidationErrorsWithSchema(
1155+
schema,
1156+
OverlappingFieldsCanBeMergedRule,
1157+
`
1158+
{
1159+
someBox {
1160+
... on IntBox {
1161+
scalar: unrelatedField
1162+
}
1163+
... on StringBox {
1164+
scalar?
1165+
}
1166+
}
1167+
}
1168+
`,
1169+
{
1170+
experimentalClientControlledNullability: true,
1171+
},
1172+
).toDeepEqual([
1173+
{
1174+
message:
1175+
'Fields "scalar" conflict because they have conflicting nullability designators "" and "?". Use different aliases on the fields to fetch both if this was intentional.',
1176+
locations: [
1177+
{ line: 5, column: 17 },
1178+
{ line: 8, column: 17 },
1179+
],
1180+
},
1181+
]);
1182+
// TODO: need one with list designators
1183+
});
1184+
10521185
it('same wrapped scalar return types', () => {
10531186
expectValidWithSchema(
10541187
schema,

0 commit comments

Comments
 (0)