You are here

protected function Server::getErrorFormatter in GraphQL 8.4

Returns the error formatter.

Allows to replace the default error formatter with a custom one. It is essential when there is a need to adjust error format, for instance to add an additional fields or remove some of the default ones.

Return value

mixed|callable The error formatter.

See also

\GraphQL\Error\FormattedError::prepareFormatter

File

src/Entity/Server.php, line 349

Class

Server
The main GraphQL configuration and request entry point.

Namespace

Drupal\graphql\Entity

Code

protected function getErrorFormatter() {
  return function (Error $error) {
    return FormattedError::createFromException($error);
  };
}