Fixed reported path for error; deprecated old FormattedError tool

This commit is contained in:
vladar 2016-10-21 04:47:07 +07:00
parent 2369454687
commit c25a29213c
3 changed files with 9 additions and 4 deletions

View File

@ -95,7 +95,7 @@ class Error extends \Exception implements \JsonSerializable
*/ */
public static function formatError(Error $error) public static function formatError(Error $error)
{ {
return FormattedError::create($error->getMessage(), $error->getLocations()); return $error->toSerializableArray();
} }
/** /**
@ -179,7 +179,10 @@ class Error extends \Exception implements \JsonSerializable
'message' => $this->getMessage(), 'message' => $this->getMessage(),
]; ];
$locations = Utils::map($this->getLocations(), function(SourceLocation $loc) {return $loc->toArray();}); $locations = Utils::map($this->getLocations(), function(SourceLocation $loc) {
return $loc->toSerializableArray();
});
if (!empty($locations)) { if (!empty($locations)) {
$arr['locations'] = $locations; $arr['locations'] = $locations;
} }

View File

@ -222,8 +222,9 @@ class Executor
{ {
$results = []; $results = [];
foreach ($fields as $responseName => $fieldASTs) { foreach ($fields as $responseName => $fieldASTs) {
$path[] = $responseName; $fieldPath = $path;
$result = self::resolveField($exeContext, $parentType, $sourceValue, $fieldASTs, $path); $fieldPath[] = $responseName;
$result = self::resolveField($exeContext, $parentType, $sourceValue, $fieldASTs, $fieldPath);
if ($result !== self::$UNDEFINED) { if ($result !== self::$UNDEFINED) {
// Undefined means that field is not defined in schema // Undefined means that field is not defined in schema

View File

@ -6,6 +6,7 @@ use GraphQL\Language\SourceLocation;
class FormattedError class FormattedError
{ {
/** /**
* @deprecated since 2016-10-21
* @param $error * @param $error
* @param SourceLocation[] $locations * @param SourceLocation[] $locations
* @return array * @return array