Skip to content

Commit

Permalink
Merge pull request #160 from mcg-web/white-list-user-error
Browse files Browse the repository at this point in the history
Add GraphQL native UserError to white list
  • Loading branch information
mcg-web authored May 30, 2017
2 parents 41059c2 + b883c5a commit 936900b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Error/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Overblog\GraphQLBundle\Error;

use GraphQL\Error\Error as GraphQLError;
use GraphQL\Error\InvariantViolation;
use GraphQL\Error\UserError as GraphQLUserError;
use GraphQL\Executor\ExecutionResult;
use Psr\Log\LoggerInterface;
use Psr\Log\LogLevel;
Expand Down Expand Up @@ -85,7 +85,7 @@ protected function treatExceptions(array $errors, $throwRawException)
$rawException = $this->convertException($error->getPrevious());

// raw GraphQL Error or InvariantViolation exception
if (null === $rawException || $rawException instanceof InvariantViolation) {
if (null === $rawException || $rawException instanceof GraphQLUserError) {
$treatedExceptions['errors'][] = $error;
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/Error/ErrorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Overblog\GraphQLBundle\Tests\Error;

use GraphQL\Error\Error as GraphQLError;
use GraphQL\Error\InvariantViolation;
use GraphQL\Error\UserError as GraphQLUserError;
use GraphQL\Executor\ExecutionResult;
use Overblog\GraphQLBundle\Error\ErrorHandler;
use Overblog\GraphQLBundle\Error\UserError;
Expand All @@ -39,7 +39,7 @@ public function testMaskErrorWithThrowExceptionSetToFalse()
new GraphQLError('Error with wrapped user error', null, null, null, null, new UserError('My User Error')),
new GraphQLError('', null, null, null, null, new UserErrors(['My User Error 1', 'My User Error 2', new UserError('My User Error 3')])),
new GraphQLError('Error with wrapped user warning', null, null, null, null, new UserWarning('My User Warning')),
new GraphQLError('Invalid value!', null, null, null, null, new InvariantViolation('Invalid value!')),
new GraphQLError('Invalid value!', null, null, null, null, new GraphQLUserError('Invalid value!')),
]
);

Expand Down

0 comments on commit 936900b

Please sign in to comment.