Moved all error-related classes to separate namespace; fixed related broken tests

This commit is contained in:
vladar 2016-10-21 16:39:57 +07:00
parent 2b305ad6e2
commit 2675b65095
81 changed files with 399 additions and 338 deletions

View File

@ -1,207 +1,18 @@
<?php
namespace GraphQL;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;
trigger_error(
'GraphQL\Error was moved to GraphQL\Error\Error and will be deleted on next release',
E_USER_DEPRECATED
);
/**
* Class Error
* A GraphQLError describes an Error found during the parse, validate, or
* execute phases of performing a GraphQL operation. In addition to a message
* and stack trace, it also includes information about the locations in a
* GraphQL document and/or execution result that correspond to the Error.
*
* @deprecated since 2016-10-21 in favor of GraphQL\Error\Error
* @package GraphQL
*/
class Error extends \Exception implements \JsonSerializable
class Error extends \GraphQL\Error\Error
{
/**
* A message describing the Error for debugging purposes.
*
* @var string
*/
public $message;
/**
* An array of [ line => x, column => y] locations within the source GraphQL document
* which correspond to this error.
*
* Errors during validation often contain multiple locations, for example to
* point out two things with the same name. Errors during execution include a
* single location, the field which produced the error.
*
* @var SourceLocation[]
*/
private $locations;
/**
* An array describing the JSON-path into the execution response which
* corresponds to this error. Only included for errors during execution.
*
* @var array
*/
public $path;
/**
* An array of GraphQL AST Nodes corresponding to this error.
*
* @var array
*/
public $nodes;
/**
* The source GraphQL document corresponding to this error.
*
* @var Source|null
*/
private $source;
/**
* @var array
*/
private $positions;
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*
* @param $error
* @param array|null $nodes
* @param array|null $path
* @return Error
*/
public static function createLocatedError($error, $nodes = null, $path = null)
{
if ($error instanceof self) {
return $error;
}
if ($error instanceof \Exception) {
$message = $error->getMessage();
$previous = $error;
} else {
$message = (string) $error;
$previous = null;
}
return new Error($message, $nodes, null, null, $path, $previous);
}
/**
* @param Error $error
* @return array
*/
public static function formatError(Error $error)
{
return $error->toSerializableArray();
}
/**
* @param string $message
* @param array|null $nodes
* @param Source $source
* @param array|null $positions
* @param array|null $path
* @param \Exception $previous
*/
public function __construct($message, $nodes = null, Source $source = null, $positions = null, $path = null, \Exception $previous = null)
{
parent::__construct($message, 0, $previous);
if ($nodes instanceof \Traversable) {
$nodes = iterator_to_array($nodes);
}
$this->nodes = $nodes;
$this->source = $source;
$this->positions = $positions;
$this->path = $path;
}
/**
* @return Source|null
*/
public function getSource()
{
if (null === $this->source) {
if (!empty($this->nodes[0]) && !empty($this->nodes[0]->loc)) {
$this->source = $this->nodes[0]->loc->source;
}
}
return $this->source;
}
/**
* @return array
*/
public function getPositions()
{
if (null === $this->positions) {
if (!empty($this->nodes)) {
$positions = array_map(function($node) { return isset($node->loc) ? $node->loc->start : null; }, $this->nodes);
$this->positions = array_filter($positions, function($p) {return $p !== null;});
}
}
return $this->positions;
}
/**
* @return SourceLocation[]
*/
public function getLocations()
{
if (null === $this->locations) {
$positions = $this->getPositions();
$source = $this->getSource();
if ($positions && $source) {
$this->locations = array_map(function ($pos) use ($source) {
return $source->getLocation($pos);
}, $positions);
} else {
$this->locations = [];
}
}
return $this->locations;
}
/**
* Returns array representation of error suitable for serialization
*
* @return array
*/
public function toSerializableArray()
{
$arr = [
'message' => $this->getMessage(),
];
$locations = Utils::map($this->getLocations(), function(SourceLocation $loc) {
return $loc->toSerializableArray();
});
if (!empty($locations)) {
$arr['locations'] = $locations;
}
if (!empty($this->path)) {
$arr['path'] = $this->path;
}
return $arr;
}
/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
function jsonSerialize()
{
return $this->toSerializableArray();
}
}

208
src/Error/Error.php Normal file
View File

@ -0,0 +1,208 @@
<?php
namespace GraphQL\Error;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;
use GraphQL\Utils;
/**
* Class Error
* A GraphQLError describes an Error found during the parse, validate, or
* execute phases of performing a GraphQL operation. In addition to a message
* and stack trace, it also includes information about the locations in a
* GraphQL document and/or execution result that correspond to the Error.
*
* @package GraphQL
*/
class Error extends \Exception implements \JsonSerializable
{
/**
* A message describing the Error for debugging purposes.
*
* @var string
*/
public $message;
/**
* An array of [ line => x, column => y] locations within the source GraphQL document
* which correspond to this error.
*
* Errors during validation often contain multiple locations, for example to
* point out two things with the same name. Errors during execution include a
* single location, the field which produced the error.
*
* @var SourceLocation[]
*/
private $locations;
/**
* An array describing the JSON-path into the execution response which
* corresponds to this error. Only included for errors during execution.
*
* @var array
*/
public $path;
/**
* An array of GraphQL AST Nodes corresponding to this error.
*
* @var array
*/
public $nodes;
/**
* The source GraphQL document corresponding to this error.
*
* @var Source|null
*/
private $source;
/**
* @var array
*/
private $positions;
/**
* Given an arbitrary Error, presumably thrown while attempting to execute a
* GraphQL operation, produce a new GraphQLError aware of the location in the
* document responsible for the original Error.
*
* @param $error
* @param array|null $nodes
* @param array|null $path
* @return Error
*/
public static function createLocatedError($error, $nodes = null, $path = null)
{
if ($error instanceof self) {
return $error;
}
if ($error instanceof \Exception) {
$message = $error->getMessage();
$previous = $error;
} else {
$message = (string) $error;
$previous = null;
}
return new static($message, $nodes, null, null, $path, $previous);
}
/**
* @param Error $error
* @return array
*/
public static function formatError(Error $error)
{
return $error->toSerializableArray();
}
/**
* @param string $message
* @param array|null $nodes
* @param Source $source
* @param array|null $positions
* @param array|null $path
* @param \Exception $previous
*/
public function __construct($message, $nodes = null, Source $source = null, $positions = null, $path = null, \Exception $previous = null)
{
parent::__construct($message, 0, $previous);
if ($nodes instanceof \Traversable) {
$nodes = iterator_to_array($nodes);
}
$this->nodes = $nodes;
$this->source = $source;
$this->positions = $positions;
$this->path = $path;
}
/**
* @return Source|null
*/
public function getSource()
{
if (null === $this->source) {
if (!empty($this->nodes[0]) && !empty($this->nodes[0]->loc)) {
$this->source = $this->nodes[0]->loc->source;
}
}
return $this->source;
}
/**
* @return array
*/
public function getPositions()
{
if (null === $this->positions) {
if (!empty($this->nodes)) {
$positions = array_map(function($node) { return isset($node->loc) ? $node->loc->start : null; }, $this->nodes);
$this->positions = array_filter($positions, function($p) {return $p !== null;});
}
}
return $this->positions;
}
/**
* @return SourceLocation[]
*/
public function getLocations()
{
if (null === $this->locations) {
$positions = $this->getPositions();
$source = $this->getSource();
if ($positions && $source) {
$this->locations = array_map(function ($pos) use ($source) {
return $source->getLocation($pos);
}, $positions);
} else {
$this->locations = [];
}
}
return $this->locations;
}
/**
* Returns array representation of error suitable for serialization
*
* @return array
*/
public function toSerializableArray()
{
$arr = [
'message' => $this->getMessage(),
];
$locations = Utils::map($this->getLocations(), function(SourceLocation $loc) {
return $loc->toSerializableArray();
});
if (!empty($locations)) {
$arr['locations'] = $locations;
}
if (!empty($this->path)) {
$arr['path'] = $this->path;
}
return $arr;
}
/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
function jsonSerialize()
{
return $this->toSerializableArray();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace GraphQL\Error;
use GraphQL\Language\SourceLocation;
class FormattedError
{
/**
* @deprecated since 2016-10-21
* @param $error
* @param SourceLocation[] $locations
* @return array
*/
public static function create($error, array $locations = [])
{
$formatted = [
'message' => $error
];
if (!empty($locations)) {
$formatted['locations'] = array_map(function($loc) { return $loc->toArray();}, $locations);
}
return $formatted;
}
}

54
src/Error/SyntaxError.php Normal file
View File

@ -0,0 +1,54 @@
<?php
namespace GraphQL\Error;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;
/**
* Class SyntaxError
* @package GraphQL\Error
*/
class SyntaxError extends Error
{
/**
* @param Source $source
* @param int $position
* @param string $description
*/
public function __construct(Source $source, $position, $description)
{
$location = $source->getLocation($position);
$syntaxError =
"Syntax Error {$source->name} ({$location->line}:{$location->column}) $description\n\n" .
self::highlightSourceAtLocation($source, $location);
parent::__construct($syntaxError, null, $source, [$position]);
}
/**
* @param Source $source
* @param SourceLocation $location
* @return string
*/
public static function highlightSourceAtLocation(Source $source, SourceLocation $location)
{
$line = $location->line;
$prevLineNum = (string)($line - 1);
$lineNum = (string)$line;
$nextLineNum = (string)($line + 1);
$padLen = mb_strlen($nextLineNum, 'UTF-8');
$unicodeChars = json_decode('"\u2028\u2029"'); // Quick hack to get js-compatible representation of these chars
$lines = preg_split('/\r\n|[\n\r' . $unicodeChars . ']/su', $source->body);
$lpad = function($len, $str) {
return str_pad($str, $len - mb_strlen($str, 'UTF-8') + 1, ' ', STR_PAD_LEFT);
};
return
($line >= 2 ? $lpad($padLen, $prevLineNum) . ': ' . $lines[$line - 2] . "\n" : '') .
($lpad($padLen, $lineNum) . ': ' . $lines[$line - 1] . "\n") .
(str_repeat(' ', 1 + $padLen + $location->column) . "^\n") .
($line < count($lines) ? $lpad($padLen, $nextLineNum) . ': ' . $lines[$line] . "\n" : '');
}
}

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Executor;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\OperationDefinition;
use GraphQL\Schema;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Executor;
use GraphQL\Error;
use GraphQL\Error\Error;
class ExecutionResult
{
@ -44,7 +44,7 @@ class ExecutionResult
}
if (!empty($this->errors)) {
$result['errors'] = array_map(['GraphQL\Error', 'formatError'], $this->errors);
$result['errors'] = array_map(['GraphQL\Error\Error', 'formatError'], $this->errors);
}
if (!empty($this->extensions)) {

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Executor;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Document;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\FragmentDefinition;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Executor;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument;
use GraphQL\Language\AST\VariableDefinition;
use GraphQL\Language\Printer;

View File

@ -1,26 +1,16 @@
<?php
namespace GraphQL;
use GraphQL\Language\SourceLocation;
trigger_error(
'GraphQL\FormattedError was moved to GraphQL\Error\FormattedError and will be deleted on next release',
E_USER_DEPRECATED
);
class FormattedError
/**
* Class FormattedError
* @deprecated since 2016-10-21 in favor of GraphQL\Error\FormattedError
* @package GraphQL
*/
class FormattedError extends \GraphQL\Error\FormattedError
{
/**
* @deprecated since 2016-10-21
* @param $error
* @param SourceLocation[] $locations
* @return array
*/
public static function create($error, array $locations = [])
{
$formatted = [
'message' => $error
];
if (!empty($locations)) {
$formatted['locations'] = array_map(function($loc) { return $loc->toArray();}, $locations);
}
return $formatted;
}
}

View File

@ -1,6 +1,7 @@
<?php
namespace GraphQL;
use GraphQL\Error\Error;
use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Executor;
use GraphQL\Language\AST\Document;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Language;
use GraphQL\SyntaxError;
use GraphQL\Error\SyntaxError;
use GraphQL\Utils;
/**

View File

@ -41,7 +41,7 @@ use GraphQL\Language\AST\TypeSystemDefinition;
use GraphQL\Language\AST\UnionTypeDefinition;
use GraphQL\Language\AST\Variable;
use GraphQL\Language\AST\VariableDefinition;
use GraphQL\SyntaxError;
use GraphQL\Error\SyntaxError;
class Parser
{

View File

@ -1,45 +1,16 @@
<?php
namespace GraphQL;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;
trigger_error(
'GraphQL\SyntaxError was moved to GraphQL\Error\SyntaxError and will be deleted on next release',
E_USER_DEPRECATED
);
class SyntaxError extends Error
/**
* Class SyntaxError
* @deprecated since 2016-10-21 in favor of GraphQL\Error\SyntaxError
* @package GraphQL
*/
class SyntaxError extends \GraphQL\Error\SyntaxError
{
/**
* @param Source $source
* @param int $position
* @param string $description
*/
public function __construct(Source $source, $position, $description)
{
$location = $source->getLocation($position);
$syntaxError =
"Syntax Error {$source->name} ({$location->line}:{$location->column}) $description\n\n" .
self::highlightSourceAtLocation($source, $location);
parent::__construct($syntaxError, null, $source, [$position]);
}
public static function highlightSourceAtLocation(Source $source, SourceLocation $location)
{
$line = $location->line;
$prevLineNum = (string)($line - 1);
$lineNum = (string)$line;
$nextLineNum = (string)($line + 1);
$padLen = mb_strlen($nextLineNum, 'UTF-8');
$unicodeChars = json_decode('"\u2028\u2029"'); // Quick hack to get js-compatible representation of these chars
$lines = preg_split('/\r\n|[\n\r' . $unicodeChars . ']/su', $source->body);
$lpad = function($len, $str) {
return str_pad($str, $len - mb_strlen($str, 'UTF-8') + 1, ' ', STR_PAD_LEFT);
};
return
($line >= 2 ? $lpad($padLen, $prevLineNum) . ': ' . $lines[$line - 2] . "\n" : '') .
($lpad($padLen, $lineNum) . ': ' . $lines[$line - 1] . "\n") .
(str_repeat(' ', 1 + $padLen + $location->column) . "^\n") .
($line < count($lines) ? $lpad($padLen, $nextLineNum) . ': ' . $lines[$line] . "\n" : '');
}
}

View File

@ -178,9 +178,9 @@ class Config
if ($def->flags & self::KEY_AS_NAME) {
$arrValue += ['name' => $arrKey];
}
self::validateMap($typeName, $arrValue, $def->definition, "$pathStr: $arrKey");
self::validateMap($typeName, $arrValue, $def->definition, "$pathStr:$arrKey");
} else {
self::validateEntry($typeName, $arrKey, $arrValue, $def->definition, "$pathStr: $arrKey");
self::validateEntry($typeName, $arrKey, $arrValue, $def->definition, "$pathStr:$arrKey");
}
}
} else {

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Type;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Schema;
use GraphQL\Type\Definition\FieldArgument;
use GraphQL\Type\Definition\FieldDefinition;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\ListValue;
use GraphQL\Language\AST\Document;
use GraphQL\Language\AST\FragmentSpread;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\VariableDefinition;
use GraphQL\Language\Printer;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\Node;
use GraphQL\Schema;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition;
use GraphQL\Language\AST\InlineFragment;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument;
use GraphQL\Language\AST\Node;
use GraphQL\Utils;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\FragmentDefinition;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\Node;
use GraphQL\Validator\ValidationContext;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Name;
use GraphQL\Language\AST\NamedType;
use GraphQL\Language\AST\Node;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Document;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\OperationDefinition;

View File

@ -9,7 +9,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentDefinition;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\OperationDefinition;
use GraphQL\Language\Visitor;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\FragmentSpread;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\InlineFragment;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Directive;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\Node;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Executor\Values;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\FragmentSpread;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\InlineFragment;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Field;
use GraphQL\Language\AST\Node;
use GraphQL\Type\Definition\Type;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument;
use GraphQL\Language\AST\Node;
use GraphQL\Language\Visitor;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Argument;
use GraphQL\Language\AST\FragmentDefinition;
use GraphQL\Language\AST\Node;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\ObjectField;
use GraphQL\Language\Visitor;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\OperationDefinition;
use GraphQL\Language\Visitor;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\VariableDefinition;
use GraphQL\Validator\ValidationContext;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\VariableDefinition;
use GraphQL\Language\Printer;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Validator\Rules;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\AST\FragmentSpread;
use GraphQL\Language\AST\Node;
use GraphQL\Language\AST\OperationDefinition;

View File

@ -7,7 +7,7 @@ use GraphQL\Language\AST\OperationDefinition;
use GraphQL\Language\AST\Variable;
use GraphQL\Language\Visitor;
use \SplObjectStorage;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Schema;
use GraphQL\Language\AST\Document;
use GraphQL\Language\AST\FragmentDefinition;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Language\Parser;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;

View File

@ -5,7 +5,7 @@ require_once __DIR__ . '/TestClasses.php';
use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Executor;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\GraphQL;
use GraphQL\Language\Parser;
use GraphQL\Language\SourceLocation;

View File

@ -3,9 +3,9 @@ namespace GraphQL\Tests\Executor;
require_once __DIR__ . '/TestClasses.php';
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Executor\Executor;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Parser;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -1,9 +1,9 @@
<?php
namespace GraphQL\Tests\Executor;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Executor\Executor;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Parser;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Tests\Executor;
use GraphQL\Executor\Executor;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Parser;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -1,9 +1,9 @@
<?php
namespace GraphQL\Tests\Executor;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Executor\Executor;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Parser;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -3,9 +3,9 @@ namespace GraphQL\Tests\Executor;
require_once __DIR__ . '/TestClasses.php';
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\Executor\Executor;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Parser;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -4,7 +4,7 @@ namespace GraphQL\Tests\Language;
use GraphQL\Language\Lexer;
use GraphQL\Language\Source;
use GraphQL\Language\Token;
use GraphQL\SyntaxError;
use GraphQL\Error\SyntaxError;
use GraphQL\Utils;
class LexerTest extends \PHPUnit_Framework_TestCase

View File

@ -14,7 +14,7 @@ use GraphQL\Language\AST\StringValue;
use GraphQL\Language\Parser;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;
use GraphQL\SyntaxError;
use GraphQL\Error\SyntaxError;
use GraphQL\Utils;
class ParserTest extends \PHPUnit_Framework_TestCase
@ -96,7 +96,7 @@ fragment MissingOn Type
*/
public function testDoesNotAcceptFragmentsNamedOn()
{
$this->setExpectedException('GraphQL\SyntaxError', 'Syntax Error GraphQL (1:10) Unexpected Name "on"');
$this->setExpectedException('GraphQL\Error\SyntaxError', 'Syntax Error GraphQL (1:10) Unexpected Name "on"');
Parser::parse('fragment on on on { on }');
}
@ -105,7 +105,7 @@ fragment MissingOn Type
*/
public function testDoesNotAcceptFragmentSpreadOfOn()
{
$this->setExpectedException('GraphQL\SyntaxError', 'Syntax Error GraphQL (1:9) Expected Name, found }');
$this->setExpectedException('GraphQL\Error\SyntaxError', 'Syntax Error GraphQL (1:9) Expected Name, found }');
Parser::parse('{ ...on }');
}
@ -114,7 +114,7 @@ fragment MissingOn Type
*/
public function testDoesNotAllowNullAsValue()
{
$this->setExpectedException('GraphQL\SyntaxError', 'Syntax Error GraphQL (1:39) Unexpected Name "null"');
$this->setExpectedException('GraphQL\Error\SyntaxError', 'Syntax Error GraphQL (1:39) Unexpected Name "null"');
Parser::parse('{ fieldWithNullableStringInput(input: null) }');
}

View File

@ -593,7 +593,7 @@ input Hello {
input Hello {
world(foo: Int): String
}';
$this->setExpectedException('GraphQL\SyntaxError');
$this->setExpectedException('GraphQL\Error\SyntaxError');
Parser::parse($body);
}

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Type;
use GraphQL\Error;
use GraphQL\Error\Error;
use GraphQL\GraphQL;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Type;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;
use GraphQL\GraphQL;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Parser;
use GraphQL\Type\Introspection;
use GraphQL\Validator\DocumentValidator;
@ -46,7 +46,7 @@ abstract class AbstractQuerySecurityTest extends \PHPUnit_Framework_TestCase
[$this->getRule($max)]
);
$this->assertEquals($expectedErrors, array_map(['GraphQL\Error', 'formatError'], $errors), $queryString);
$this->assertEquals($expectedErrors, array_map(['GraphQL\Error\Error', 'formatError'], $errors), $queryString);
return $errors;
}

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\ArgumentsOfCorrectType;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Messages;
use GraphQL\Validator\Rules\DefaultValuesOfCorrectType;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Messages;
use GraphQL\Validator\Rules\FieldsOnCorrectType;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\FragmentsOnCompositeTypes;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\KnownArgumentNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\KnownDirectives;

View File

@ -2,7 +2,7 @@
namespace GraphQL\Tests\Validator;
use GraphQL\Validator\Rules\KnownFragmentNames;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
class KnownFragmentNamesTest extends TestCase

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\KnownTypeNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\LoneAnonymousOperation;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\NoFragmentCycles;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\NoUndefinedVariables;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\NoUnusedFragments;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\NoUnusedVariables;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\Source;
use GraphQL\Language\SourceLocation;
use GraphQL\Schema;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\PossibleFragmentSpreads;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\ProvidedNonNullArguments;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\ScalarLeafs;

View File

@ -316,7 +316,7 @@ abstract class TestCase extends \PHPUnit_Framework_TestCase
$errors = DocumentValidator::validate($schema, Parser::parse($queryString), $rules);
$this->assertNotEmpty($errors, 'GraphQL should not validate');
$this->assertEquals($expectedErrors, array_map(['GraphQL\Error', 'formatError'], $errors));
$this->assertEquals($expectedErrors, array_map(['GraphQL\Error\Error', 'formatError'], $errors));
return $errors;
}

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\UniqueArgumentNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\UniqueFragmentNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\UniqueInputFieldNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\UniqueOperationNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\UniqueVariableNames;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Rules\VariablesAreInputTypes;

View File

@ -1,7 +1,7 @@
<?php
namespace GraphQL\Tests\Validator;
use GraphQL\FormattedError;
use GraphQL\Error\FormattedError;
use GraphQL\Language\SourceLocation;
use GraphQL\Validator\Messages;
use GraphQL\Validator\Rules\VariablesInAllowedPosition;