Skip to content

Commit

Permalink
Improve validation error message when field names conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Zhu committed Apr 21, 2016
1 parent dd02973 commit aa72089
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/validation/rules/OverlappingFieldsCanBeMerged.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ export function fieldsConflictMessage(
responseName: string,
reason: ConflictReasonMessage
): string {
return `Fields "${responseName}" conflict because ${reasonMessage(reason)}.`;
return `Fields "${responseName}" conflict because ${reasonMessage(reason)}` +
'. Use aliases on the fields to fetch both if this was intentional.';
}

function reasonMessage(reason: ConflictReasonMessage): string {
if (Array.isArray(reason)) {
return reason.map(([ responseName, subreason ]) =>
`subfields "${responseName}" conflict because ${reasonMessage(subreason)}`
).join(' and ');
).join(' and ') +
'. Use aliases on the fields to fetch both if this was intentional.';
}
return reason;
}
Expand Down

0 comments on commit aa72089

Please sign in to comment.