diff --git a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php index d0a0fb0..95b0e86 100644 --- a/src/Validator/Rules/OverlappingFieldsCanBeMerged.php +++ b/src/Validator/Rules/OverlappingFieldsCanBeMerged.php @@ -28,7 +28,7 @@ class OverlappingFieldsCanBeMerged extends AbstractValidationRule static function fieldsConflictMessage($responseName, $reason) { $reasonMessage = self::reasonMessage($reason); - return "Fields \"$responseName\" conflict because $reasonMessage."; + return "Fields \"$responseName\" conflict because $reasonMessage. Use different aliases on the fields to fetch both if this was intentional."; } static function reasonMessage($reason) diff --git a/tests/Validator/OverlappingFieldsCanBeMergedTest.php b/tests/Validator/OverlappingFieldsCanBeMergedTest.php index 4c65960..84bcf29 100644 --- a/tests/Validator/OverlappingFieldsCanBeMergedTest.php +++ b/tests/Validator/OverlappingFieldsCanBeMergedTest.php @@ -785,6 +785,19 @@ class OverlappingFieldsCanBeMergedTest extends TestCase '); } + /** + * @it error message contains hint for alias conflict + */ + public function testErrorMessageContainsHintForAliasConflict() + { + // The error template should end with a hint for the user to try using + // different aliases. + $error = OverlappingFieldsCanBeMerged::fieldsConflictMessage('x', 'a and b are different fields'); + $hint = 'Use different aliases on the fields to fetch both if this was intentional.'; + + $this->assertStringEndsWith($hint, $error); + } + private function getSchema() { $StringBox = null;