diff --git a/src/Error.php b/src/Error.php index 54edb52..6b46c3b 100644 --- a/src/Error.php +++ b/src/Error.php @@ -95,7 +95,7 @@ class Error extends \Exception implements \JsonSerializable */ 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(), ]; - $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)) { $arr['locations'] = $locations; } diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 7c4d94c..48632af 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -222,8 +222,9 @@ class Executor { $results = []; foreach ($fields as $responseName => $fieldASTs) { - $path[] = $responseName; - $result = self::resolveField($exeContext, $parentType, $sourceValue, $fieldASTs, $path); + $fieldPath = $path; + $fieldPath[] = $responseName; + $result = self::resolveField($exeContext, $parentType, $sourceValue, $fieldASTs, $fieldPath); if ($result !== self::$UNDEFINED) { // Undefined means that field is not defined in schema diff --git a/src/FormattedError.php b/src/FormattedError.php index efeee2e..934743d 100644 --- a/src/FormattedError.php +++ b/src/FormattedError.php @@ -6,6 +6,7 @@ use GraphQL\Language\SourceLocation; class FormattedError { /** + * @deprecated since 2016-10-21 * @param $error * @param SourceLocation[] $locations * @return array