protected function Server::getValidationRules in GraphQL 8.4
Returns the validation rules to use for the query.
@todo Handle this through configurable plugins on the server.
May return a callable to allow the server to decide the validation rules independently for each query operation.
public function getValidationRules() {
return function (OperationParams $params, DocumentNode $document, $operation) {
if (isset($params->queryId)) {
// Assume that pre-parsed documents are already validated. This allows
// us to store pre-validated query documents e.g. for persisted queries
// effectively improving performance by skipping run-time validation.
return [];
}
return array_values(DocumentValidator::defaultRules());
};
}
Return value
array|callable The validation rules or a callable factory.
1 call to Server::getValidationRules()
- Server::configuration in src/
Entity/ Server.php
File
- src/
Entity/ Server.php, line 492
Class
- Server
- The main GraphQL configuration and request entry point.
Namespace
Drupal\graphql\EntityCode
protected function getValidationRules() {
return function (OperationParams $params, DocumentNode $document, $operation) {
if (isset($params->queryId)) {
// Assume that pre-parsed documents are already validated. This allows
// us to store pre-validated query documents e.g. for persisted queries
// effectively improving performance by skipping run-time validation.
return [];
}
return array_values(DocumentValidator::defaultRules());
};
}