Skip to content

Commit

Permalink
Added throw UserError exception for UnauthorizedException
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszdebinski committed Aug 4, 2023
2 parents 871251d + d4a9610 commit 6a63387
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/lib/Resolver/SectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@
*/
namespace Ibexa\GraphQL\Resolver;

use Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException;
use Ibexa\Contracts\Core\Repository\Values\Content\Section;
use Ibexa\Contracts\Core\Repository\SectionService;
use GraphQL\Error\UserError;

/**
* @internal
*/
class SectionResolver
{
/**
* @var \Ibexa\Contracts\Core\Repository\SectionService
*/
private $sectionService;
private SectionService $sectionService;

public function __construct(SectionService $sectionService)
{
$this->sectionService = $sectionService;
}

public function resolveSectionById($sectionId)
public function resolveSectionById($sectionId): ?Section
{
return $this->sectionService->loadSection($sectionId);
try {
return $this->sectionService->loadSection($sectionId);
} catch (UnauthorizedException $e) {
throw new UserError($e->getMessage());
}
}
}

Expand Down

0 comments on commit 6a63387

Please sign in to comment.