57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace dominion\file\schema;
|
|
|
|
use GraphQL\Type\Definition\ObjectType;
|
|
use GraphQL\Type\Definition\Type;
|
|
use dominion\file\File;
|
|
|
|
class FileTemplateType extends ObjectType
|
|
{
|
|
public function __construct()
|
|
{
|
|
$config = [
|
|
'fields' => function() {
|
|
return [
|
|
'id' => [
|
|
'type' => Type::int(),
|
|
'description' => 'Id',
|
|
],
|
|
'description' => [
|
|
'type' => Type::string(),
|
|
'description' => 'Описание',
|
|
],
|
|
'originalName' => [
|
|
'type' => Type::string(),
|
|
'description' => 'Название файла при загрузке',
|
|
],
|
|
'ext' => [
|
|
'type' => Type::string(),
|
|
'description' => 'ext',
|
|
],
|
|
'fileSize' => [
|
|
'type' => Type::int(),
|
|
'description' => 'fileSize',
|
|
],
|
|
'file' => [
|
|
'type' => Type::string(),
|
|
'description' => 'Путь к файлу',
|
|
'resolve' => function($root, $args) {
|
|
return File::getPathFull($root->id);
|
|
}
|
|
],
|
|
'size' => [
|
|
'type' => Type::string(),
|
|
'description' => 'Размер файла',
|
|
'resolve' => function($root, $args) {
|
|
return $root->size;
|
|
}
|
|
],
|
|
];
|
|
}
|
|
];
|
|
|
|
parent::__construct($config);
|
|
}
|
|
|
|
} |