Skip to content

Commit 936900b

Browse files
authored
Merge pull request #160 from mcg-web/white-list-user-error
Add GraphQL native UserError to white list
2 parents 41059c2 + b883c5a commit 936900b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Error/ErrorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Overblog\GraphQLBundle\Error;
1313

1414
use GraphQL\Error\Error as GraphQLError;
15-
use GraphQL\Error\InvariantViolation;
15+
use GraphQL\Error\UserError as GraphQLUserError;
1616
use GraphQL\Executor\ExecutionResult;
1717
use Psr\Log\LoggerInterface;
1818
use Psr\Log\LogLevel;
@@ -85,7 +85,7 @@ protected function treatExceptions(array $errors, $throwRawException)
8585
$rawException = $this->convertException($error->getPrevious());
8686

8787
// raw GraphQL Error or InvariantViolation exception
88-
if (null === $rawException || $rawException instanceof InvariantViolation) {
88+
if (null === $rawException || $rawException instanceof GraphQLUserError) {
8989
$treatedExceptions['errors'][] = $error;
9090
continue;
9191
}

Tests/Error/ErrorHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Overblog\GraphQLBundle\Tests\Error;
1313

1414
use GraphQL\Error\Error as GraphQLError;
15-
use GraphQL\Error\InvariantViolation;
15+
use GraphQL\Error\UserError as GraphQLUserError;
1616
use GraphQL\Executor\ExecutionResult;
1717
use Overblog\GraphQLBundle\Error\ErrorHandler;
1818
use Overblog\GraphQLBundle\Error\UserError;
@@ -39,7 +39,7 @@ public function testMaskErrorWithThrowExceptionSetToFalse()
3939
new GraphQLError('Error with wrapped user error', null, null, null, null, new UserError('My User Error')),
4040
new GraphQLError('', null, null, null, null, new UserErrors(['My User Error 1', 'My User Error 2', new UserError('My User Error 3')])),
4141
new GraphQLError('Error with wrapped user warning', null, null, null, null, new UserWarning('My User Warning')),
42-
new GraphQLError('Invalid value!', null, null, null, null, new InvariantViolation('Invalid value!')),
42+
new GraphQLError('Invalid value!', null, null, null, null, new GraphQLUserError('Invalid value!')),
4343
]
4444
);
4545

0 commit comments

Comments
 (0)