init
This commit is contained in:
64
schema/FileType.php
Normal file
64
schema/FileType.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace dominion\file\schema;
|
||||
|
||||
use GraphQL\Type\Definition\ObjectType;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
use dominion\file\File;
|
||||
|
||||
class FileType 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' => 'Путь к файлу',
|
||||
'args' => [
|
||||
'type' => [
|
||||
'type' => Type::string(),
|
||||
'description' => "Тип миниатюры ('snippet', 'small', 'medium', 'large', 'landing', 'adv1080') по умолчанию нет",
|
||||
],
|
||||
],
|
||||
'resolve' => function($root, $args) {
|
||||
$type = isset($args['type']) ? $args['type'] : null;
|
||||
return File::getPathFull($root->id, $type);
|
||||
}
|
||||
],
|
||||
'size' => [
|
||||
'type' => Type::string(),
|
||||
'description' => 'Размер файла',
|
||||
'resolve' => function($root, $args) {
|
||||
return $root->size;
|
||||
}
|
||||
],
|
||||
];
|
||||
}
|
||||
];
|
||||
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user