code: public function toArray($debug = false)
      {
          $result = [];
  
          if (! empty($this->errors)) {
              $errorsHandler = $this->errorsHandler ?: static function (array $errors, callable $formatter) {
                  return array_map($formatter, $errors);
              };
  
              $result['errors'] = $errorsHandler(
                  $this->errors,
                  FormattedError::prepareFormatter($this->errorFormatter, $debug)
              );
          }
  
          if ($this->data !== null) {
              $result['data'] = $this->data;
          }
  
          if (! empty($this->extensions)) {
              $result['extensions'] = $this->extensions;
          }
  
          return $result;
      }
docs: Converts GraphQL query result to spec-compliant serializable array using provided
  errors handler and formatter.
  
  If debug argument is passed, output of error formatter is enriched which debugging information
  ("debugMessage", "trace" keys depending on flags).
  
  $debug argument must be either bool (only adds "debugMessage" to result) or sum of flags from
  GraphQL\Error\Debug
  
  @param bool|int $debug
  
  @return mixed[]
  
  @api