kuvalda-settings/schema/SettingsPaginationType.php

49 lines
1.6 KiB
PHP
Raw Normal View History

2024-11-20 15:59:13 +03:00
<?php
namespace dominion\settings\schema;
use GraphQL\Type\Definition\Type;
use dominion\api\GraphQLSchemaPagination;
use dominion\settings\Settings;
use dominion\api\GraphQLPagination;
class SettingsPaginationType extends GraphQLSchemaPagination
{
public function __construct()
{
$config = [
'fields' => function(){
$output = $this->getCustomFields();
$output['data'] = [
'type' => Type::listOf(Types::settings()),
'description' => 'Настройки',
'args' => GraphQLPagination::argumentModify([
'id' => [
'type' => Type::int(),
'description' => 'Id',
],
'code' => [
'type' => Type::string(),
'description' => 'символьный код',
'modify' => true,
'modifyOption' => ['in'],
],
'sort' => [
'type' => Type::string(),
'description' => 'Сортировка (пример "isNew_asc" или "isVisible_desc")',
],
]),
'resolve' => function($root, $args){
return Settings::getData($args, $root);
}
];
return $output;
}
];
parent::__construct($config);
}
}