mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
Merge pull request #270 from adri/allow-validation-to-be-skipped
Validation > Performance > Return early if rules are empty to avoid visiting elements
This commit is contained in:
commit
4418f4f975
@ -86,6 +86,12 @@ class DocumentValidator
|
||||
if (null === $rules) {
|
||||
$rules = static::allRules();
|
||||
}
|
||||
|
||||
if (true === is_array($rules) && 0 === count($rules)) {
|
||||
// Skip validation if there are no rules
|
||||
return [];
|
||||
}
|
||||
|
||||
$typeInfo = $typeInfo ?: new TypeInfo($schema);
|
||||
$errors = static::visitUsingRules($schema, $typeInfo, $ast, $rules);
|
||||
return $errors;
|
||||
|
Loading…
Reference in New Issue
Block a user