mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
53 lines
1.1 KiB
PHP
53 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Schema\Queries\Auth;
|
|
|
|
use App\GraphQL\Argument\Argument;
|
|
use App\GraphQL\Schema\Queries\BaseQuery;
|
|
use App\GraphQL\Schema\Types\Auth\User\MeType;
|
|
use App\Models\Auth\User;
|
|
use GraphQL\Type\Definition\ResolveInfo;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class MeQuery extends BaseQuery
|
|
{
|
|
public function name(): string
|
|
{
|
|
return 'me';
|
|
}
|
|
|
|
public function description(): string
|
|
{
|
|
return 'Returns the data of the currently authenticated user.';
|
|
}
|
|
|
|
/**
|
|
* The arguments of the type.
|
|
*
|
|
* @return Argument[]
|
|
*/
|
|
public function arguments(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* The base return type of the query.
|
|
*/
|
|
public function baseType(): MeType
|
|
{
|
|
return new MeType();
|
|
}
|
|
|
|
public function resolve($root, array $args, $context, ResolveInfo $resolveInfo): ?User
|
|
{
|
|
$builder = User::query()->whereKey(Auth::id());
|
|
|
|
$this->constrainEagerLoads($builder, $resolveInfo, $this->baseType());
|
|
|
|
return $builder->first();
|
|
}
|
|
}
|