mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Query validation should pass if empty array of rules is provided
This commit is contained in:
parent
65d9472b0b
commit
37a42ededd
@ -118,8 +118,11 @@ class DocumentValidator
|
||||
|
||||
public static function validate(Schema $schema, DocumentNode $ast, array $rules = null, TypeInfo $typeInfo = null)
|
||||
{
|
||||
if (null === $rules) {
|
||||
$rules = static::allRules();
|
||||
}
|
||||
$typeInfo = $typeInfo ?: new TypeInfo($schema);
|
||||
$errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules ?: static::allRules());
|
||||
$errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules);
|
||||
return $errors;
|
||||
}
|
||||
|
||||
|
@ -23,4 +23,16 @@ class ValidationTest extends TestCase
|
||||
}
|
||||
');
|
||||
}
|
||||
|
||||
public function testPassesValidationWithEmptyRules()
|
||||
{
|
||||
$query = '{invalid}';
|
||||
|
||||
$expectedError = [
|
||||
'message' => 'Cannot query field "invalid" on type "QueryRoot".',
|
||||
'locations' => [ ['line' => 1, 'column' => 2] ]
|
||||
];
|
||||
$this->expectFailsCompleteValidation($query, [$expectedError]);
|
||||
$this->expectValid($this->getDefaultSchema(), [], $query);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user