Skip to content

Commit aa72089

Browse files
author
Robert Zhu
committed
Improve validation error message when field names conflict
1 parent dd02973 commit aa72089

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/validation/rules/OverlappingFieldsCanBeMerged.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,16 @@ export function fieldsConflictMessage(
3939
responseName: string,
4040
reason: ConflictReasonMessage
4141
): string {
42-
return `Fields "${responseName}" conflict because ${reasonMessage(reason)}.`;
42+
return `Fields "${responseName}" conflict because ${reasonMessage(reason)}` +
43+
'. Use aliases on the fields to fetch both if this was intentional.';
4344
}
4445

4546
function reasonMessage(reason: ConflictReasonMessage): string {
4647
if (Array.isArray(reason)) {
4748
return reason.map(([ responseName, subreason ]) =>
4849
`subfields "${responseName}" conflict because ${reasonMessage(subreason)}`
49-
).join(' and ');
50+
).join(' and ') +
51+
'. Use aliases on the fields to fetch both if this was intentional.';
5052
}
5153
return reason;
5254
}

0 commit comments

Comments
 (0)