kuvalda-settings/schema/SettingsMutationType.php

34 lines
973 B
PHP
Raw Normal View History

2024-11-20 15:59:13 +03:00
<?php
namespace dominion\settings\schema;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use dominion\settings\Settings;
class SettingsMutationType extends ObjectType
{
public function __construct()
{
$config = [
'fields' => function() {
return [
'save' => [
'type' => Type::int(),
'description' => 'Сохранение наклейки',
'args' => [
'code' => Type::nonNull(Type::string()),
'value' => Type::nonNull(Type::string()),
],
'resolve' => function($root, $args) {
return Settings::setValue($args['code'], $args['value']);
},
],
];
}
];
parent::__construct($config);
}
}