mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-09-23 04:46:07 +02:00
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\GraphQL\Definition\Fields;
|
|
|
|
use App\Contracts\GraphQL\Fields\DisplayableField;
|
|
use App\Contracts\GraphQL\Fields\FilterableField;
|
|
use App\Contracts\GraphQL\Fields\SortableField;
|
|
use App\Enums\GraphQL\SortType;
|
|
use App\GraphQL\Support\Directives\Filters\EqFilterDirective;
|
|
use App\GraphQL\Support\Directives\Filters\FilterDirective;
|
|
use App\GraphQL\Support\Directives\Filters\LikeFilterDirective;
|
|
use GraphQL\Type\Definition\Type;
|
|
|
|
abstract class StringField extends Field implements DisplayableField, FilterableField, SortableField
|
|
{
|
|
/**
|
|
* The type returned by the field.
|
|
*/
|
|
public function type(): Type
|
|
{
|
|
return Type::string();
|
|
}
|
|
|
|
/**
|
|
* Determine if the field should be displayed to the user.
|
|
*/
|
|
public function canBeDisplayed(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* The directives available for this filter.
|
|
*
|
|
* @return FilterDirective[]
|
|
*/
|
|
public function filterDirectives(): array
|
|
{
|
|
return [
|
|
new EqFilterDirective($this),
|
|
new LikeFilterDirective($this),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* The sort type of the field.
|
|
*/
|
|
public function sortType(): SortType
|
|
{
|
|
return SortType::ROOT;
|
|
}
|
|
}
|