Skip to content

Commit

Permalink
IBX-5094: Added try-catch block for UnauthorizedException
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszdebinski committed Jul 26, 2023
1 parent dbdaaae commit 2f6dffb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/GraphQL/Resolver/SectionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
namespace EzSystems\EzPlatformGraphQL\GraphQL\Resolver;

use eZ\Publish\API\Repository\Exceptions\UnauthorizedException;
use eZ\Publish\API\Repository\Values\Content\Section;
use eZ\Publish\API\Repository\SectionService;

/**
Expand All @@ -23,8 +25,12 @@ 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 $ex) {
return null;
}
}
}

0 comments on commit 2f6dffb

Please sign in to comment.