GraphQL\Error\Error::formatError PHP Метод

formatError() публичный статический Метод

public static formatError ( Error $error ) : array
$error Error
Результат array
    public static function formatError(Error $error)
    {
        return $error->toSerializableArray();
    }

Usage Example

Пример #1
0
 /**
  * @it does not allow unknown types to be used as values
  */
 public function testDoesNotAllowUnknownTypesToBeUsedAsValues()
 {
     $doc = '
     query q($input: UnknownType!) {
       fieldWithObjectInput(input: $input)
     }
     ';
     $ast = Parser::parse($doc);
     $vars = ['input' => 'whoknows'];
     try {
         Executor::execute($this->schema(), $ast, null, null, $vars);
         $this->fail('Expected exception not thrown');
     } catch (Error $error) {
         $expected = FormattedError::create('Variable "$input" expected value of type "UnknownType!" which ' . 'cannot be used as an input type.', [new SourceLocation(2, 17)]);
         $this->assertEquals($expected, Error::formatError($error));
     }
 }