mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Schema\Unions;
|
|
|
|
use App\GraphQL\Schema\Types\BaseType;
|
|
use App\GraphQL\Schema\Types\User\Notification\ExternalProfileSyncedNotificationType;
|
|
use App\Notifications\ExternalProfileSyncedNotification;
|
|
use GraphQL\Type\Definition\Type;
|
|
use Rebing\GraphQL\Support\Facades\GraphQL;
|
|
use RuntimeException;
|
|
|
|
class NotificationUnion extends BaseUnion
|
|
{
|
|
public function description(): string
|
|
{
|
|
return 'Represents the notification types.';
|
|
}
|
|
|
|
/**
|
|
* The types that this union can resolve to.
|
|
*
|
|
* @return BaseType[]
|
|
*/
|
|
public function baseTypes(): array
|
|
{
|
|
return [
|
|
new ExternalProfileSyncedNotificationType(),
|
|
];
|
|
}
|
|
|
|
public function resolveType($value): Type
|
|
{
|
|
$type = match ($value->type) {
|
|
ExternalProfileSyncedNotification::class => new ExternalProfileSyncedNotificationType(),
|
|
default => throw new RuntimeException("Type not specified for notification {$value->type}"),
|
|
};
|
|
|
|
return GraphQL::type($type->name());
|
|
}
|
|
}
|