Skip to content

Commit 8e75cc3

Browse files
committed
Merge branch 'master' of https://github.com/webonyx/graphql-php
2 parents ceaf798 + ddea764 commit 8e75cc3

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

examples/00-hello-world/graphql.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
// Test this using following command
3-
// php -S localhost:8080 ./graphql.php
4-
require_once '../../vendor/autoload.php';
3+
// php -S localhost:8080 ./graphql.php &
4+
// curl http://localhost:8080 -d "query { echo(message: \"Hello\") }"
5+
// curl http://localhost:8080 -d "mutation { sum(x: 2, y: 2) }"
6+
require_once __DIR__ . '/../../vendor/autoload.php';
57

68
use GraphQL\Type\Definition\ObjectType;
79
use GraphQL\Type\Definition\Type;

examples/01-blog/graphql.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
// Test this using following command
3-
// php -S localhost:8080 ./index.php
4-
require_once '../../vendor/autoload.php';
3+
// php -S localhost:8080 ./graphql.php
4+
require_once __DIR__ . '/../../vendor/autoload.php';
55

66
use \GraphQL\Examples\Blog\Types;
77
use \GraphQL\Examples\Blog\AppContext;

src/Error/Error.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ public static function createLocatedError($error, $nodes = null, $path = null)
8989
} else if ($error instanceof \Exception) {
9090
$message = $error->getMessage();
9191
$originalError = $error;
92+
} else if ($error instanceof \Error) {
93+
$message = $error->getMessage();
94+
$originalError = $error;
9295
} else {
9396
$message = (string) $error;
9497
}
@@ -119,9 +122,9 @@ public static function formatError(Error $error)
119122
* @param Source $source
120123
* @param array|null $positions
121124
* @param array|null $path
122-
* @param \Exception $previous
125+
* @param \Exception|\Error $previous
123126
*/
124-
public function __construct($message, $nodes = null, Source $source = null, $positions = null, $path = null, \Exception $previous = null)
127+
public function __construct($message, $nodes = null, Source $source = null, $positions = null, $path = null, $previous = null)
125128
{
126129
parent::__construct($message, 0, $previous);
127130

src/Executor/Executor.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ private function resolveOrError($fieldDef, $fieldNode, $resolveFn, $source, $con
680680
return $resolveFn($source, $args, $context, $info);
681681
} catch (\Exception $error) {
682682
return $error;
683+
} catch (\Error $error) {
684+
return $error;
683685
}
684686
}
685687

@@ -778,6 +780,8 @@ public function completeValueWithLocatedError(
778780
return $completed;
779781
} catch (\Exception $error) {
780782
throw Error::createLocatedError($error, $fieldNodes, $path);
783+
} catch (\Error $error) {
784+
throw Error::createLocatedError($error, $fieldNodes, $path);
781785
}
782786
}
783787

@@ -810,6 +814,7 @@ public function completeValueWithLocatedError(
810814
* @return array|null|Promise
811815
* @throws Error
812816
* @throws \Exception
817+
* @throws \Error
813818
*/
814819
private function completeValue(
815820
Type $returnType,
@@ -835,6 +840,10 @@ private function completeValue(
835840
throw $result;
836841
}
837842

843+
if ($result instanceof \Error) {
844+
throw $result;
845+
}
846+
838847
// If field type is NonNull, complete for inner type, and throw field error
839848
// if result is null.
840849
if ($returnType instanceof NonNull) {

0 commit comments

Comments
 (0)