You are here

protected function QueryProcessor::resolveValidationRules in GraphQL 8.3

Parameters

\GraphQL\Server\ServerConfig $config:

\GraphQL\Server\OperationParams $params:

\GraphQL\Language\AST\DocumentNode $document:

$operation:

Return value

array

Throws

\GraphQL\Server\RequestError

1 call to QueryProcessor::resolveValidationRules()
QueryProcessor::validateOperation in src/GraphQL/Execution/QueryProcessor.php

File

src/GraphQL/Execution/QueryProcessor.php, line 414

Class

QueryProcessor

Namespace

Drupal\graphql\GraphQL\Execution

Code

protected function resolveValidationRules(ServerConfig $config, OperationParams $params, DocumentNode $document, $operation) {

  // Allow customizing validation rules per operation:
  $rules = $config
    ->getValidationRules();
  if (is_callable($rules)) {
    $rules = $rules($params, $document, $operation);
    if (!is_array($rules)) {
      throw new RequestError(sprintf("Expecting validation rules to be array or callable returning array, but got: %s", Utils::printSafe($rules)));
    }
  }
  return $rules;
}