Skip to content

Commit a679bfa

Browse files
author
Mikk Mihkel Nurges
committed
Don't report AuthorizationError
1 parent ebc0652 commit a679bfa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Rebing/GraphQL/GraphQL.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use GraphQL\Error\Debug;
44
use GraphQL\Error\Error;
5+
use Rebing\GraphQL\Error\AuthorizationError;
56
use Rebing\GraphQL\Error\ValidationError;
67
use GraphQL\GraphQL as GraphQLBase;
78
use GraphQL\Type\Schema;
@@ -296,9 +297,13 @@ public static function handleErrors(array $errors, callable $formatter)
296297
foreach ($errors as $error) {
297298
// Try to unwrap exception
298299
$error = $error->getPrevious() ?: $error;
299-
if ($error instanceof \Exception && !($error instanceof ValidationError)) {
300-
$handler->report($error);
300+
// Don't report certain GraphQL errors
301+
if ($error instanceof ValidationError
302+
|| $error instanceof AuthorizationError
303+
|| !($error instanceof \Exception)) {
304+
continue;
301305
}
306+
$handler->report($error);
302307
}
303308
return array_map($formatter, $errors);
304309
}

0 commit comments

Comments
 (0)