mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 00:25:17 +03:00
Improve validation error message when field names conflict
ref: graphql/graphql-js#363
This commit is contained in:
parent
d70a9a5e53
commit
58453c31f7
@ -28,7 +28,7 @@ class OverlappingFieldsCanBeMerged extends AbstractValidationRule
|
|||||||
static function fieldsConflictMessage($responseName, $reason)
|
static function fieldsConflictMessage($responseName, $reason)
|
||||||
{
|
{
|
||||||
$reasonMessage = self::reasonMessage($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)
|
static function reasonMessage($reason)
|
||||||
|
@ -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()
|
private function getSchema()
|
||||||
{
|
{
|
||||||
$StringBox = null;
|
$StringBox = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user