Skip to content

Commit

Permalink
Merge pull request #4 from t3n/error-fix
Browse files Browse the repository at this point in the history
BUGFIX: ResolveInfo::$path is already an array in graphql-php
  • Loading branch information
Torsten85 authored Nov 29, 2018
2 parents 0d9444d + 941ee7f commit a2df4a0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/Stitching/DefaultMergedResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static function invoke($parent, array $args, $context, ResolveInfo $info)

if ($errorResult['kind'] === 'OWN') {
$error = Error::createLocatedError(
new Error($errorResult['error']->message, $info->fieldNodes, Errors::responsePathAsArray($info->path))
new Error($errorResult['error']->message),
$info->fieldNodes,
$info->path
);
throw $error;
}
Expand Down
20 changes: 1 addition & 19 deletions src/Stitching/Errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use function array_keys;
use function array_map;
use function array_merge;
use function array_reverse;
use function array_slice;
use function count;
use function implode;
Expand Down Expand Up @@ -127,7 +126,7 @@ public function __construct(string $message, array $errors)
$locatedError = Error::createLocatedError(
$newError,
$info->fieldNodes,
static::responsePathAsArray($info->path)
$info->path
);
throw $locatedError;
}
Expand All @@ -141,23 +140,6 @@ public function __construct(string $message, array $errors)
return $resultObject;
}

/**
* @param mixed[]|null $path
*
* @return mixed[]
*/
public static function responsePathAsArray(?array $path) : array
{
$flattened = [];
$curr = $path;
while ($curr) {
$flattened[] = $curr['key'];
$curr = $curr['prev'];
}

return array_reverse($flattened);
}

/**
* @param Error[] $errors
*/
Expand Down

0 comments on commit a2df4a0

Please sign in to comment.