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\OrderableField;
|
|
use App\Enums\GraphQL\OrderType;
|
|
use App\GraphQL\Definition\Directives\Filters\EqFilterDirective;
|
|
use App\GraphQL\Definition\Directives\Filters\FilterDirective;
|
|
use App\GraphQL\Definition\Directives\Filters\LikeFilterDirective;
|
|
use GraphQL\Type\Definition\Type;
|
|
|
|
abstract class StringField extends Field implements DisplayableField, FilterableField, OrderableField
|
|
{
|
|
/**
|
|
* 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, $this->type()),
|
|
new LikeFilterDirective($this, $this->type()),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* The order type of the field.
|
|
*/
|
|
public function orderType(): OrderType
|
|
{
|
|
return OrderType::ROOT;
|
|
}
|
|
}
|