Skip to content

Commit

Permalink
IBX-4109: Handled deleted users resolving (#131)
Browse files Browse the repository at this point in the history
* IBX-4109: Handled deleted users resolving

* IBX-4109: Add GraphQL warning for a missing user
  • Loading branch information
barw4 authored Feb 3, 2023
1 parent 3c1cc66 commit cbca368
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/GraphQL/Resolver/UserResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
*/
namespace EzSystems\EzPlatformGraphQL\GraphQL\Resolver;

use eZ\Publish\API\Repository\Exceptions\NotFoundException;
use eZ\Publish\API\Repository\LocationService;
use eZ\Publish\API\Repository\UserService;
use eZ\Publish\API\Repository\Values\Content\Content;
use eZ\Publish\API\Repository\Values\User\User;
use eZ\Publish\API\Repository\Values\User\UserGroup;
use Overblog\GraphQLBundle\Error\UserWarning;

/**
* @internal
Expand Down Expand Up @@ -46,9 +49,13 @@ public function resolveUser($args)
}
}

public function resolveUserById($userId)
public function resolveUserById($userId): ?User
{
return $this->userService->loadUser($userId);
try {
return $this->userService->loadUser($userId);
} catch (NotFoundException $e) {
throw new UserWarning($e->getMessage());
}
}

/**
Expand Down

0 comments on commit cbca368

Please sign in to comment.