mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Move custom types to their own class
This commit is contained in:
@@ -13,9 +13,6 @@ use Utopia\Database\Database;
|
||||
|
||||
class TypeRegistry
|
||||
{
|
||||
private static ?Json $jsonType = null;
|
||||
private static ?InputFile $inputFile = null;
|
||||
|
||||
private static array $typeMapping = [];
|
||||
private static array $defaultDocumentArgs = [];
|
||||
private static array $models = [];
|
||||
@@ -158,30 +155,5 @@ class TypeRegistry
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JSON type.
|
||||
*
|
||||
* @return Json
|
||||
*/
|
||||
public static function json(): Json
|
||||
{
|
||||
if (\is_null(self::$jsonType)) {
|
||||
self::$jsonType = new Json();
|
||||
}
|
||||
return self::$jsonType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the InputFile type.
|
||||
*
|
||||
* @return InputFile
|
||||
*/
|
||||
public static function inputFile(): InputFile
|
||||
{
|
||||
if (\is_null(self::$inputFile)) {
|
||||
self::$inputFile = new InputFile();
|
||||
}
|
||||
return self::$inputFile;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Appwrite\GraphQL;
|
||||
|
||||
use Appwrite\GraphQL\Types\InputFile;
|
||||
use Appwrite\GraphQL\Types\Json;
|
||||
use GraphQL\Type\Definition\Type;
|
||||
|
||||
class Types
|
||||
{
|
||||
/**
|
||||
* Get the JSON type.
|
||||
*
|
||||
* @return Json
|
||||
*/
|
||||
public static function json(): Type
|
||||
{
|
||||
if (TypeRegistry::has(Json::class)) {
|
||||
return TypeRegistry::get(Json::class);
|
||||
}
|
||||
$type = new Json();
|
||||
TypeRegistry::set(Json::class, $type);
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the InputFile type.
|
||||
*
|
||||
* @return InputFile
|
||||
*/
|
||||
public static function inputFile(): Type
|
||||
{
|
||||
if (TypeRegistry::has(InputFile::class)) {
|
||||
return TypeRegistry::get(InputFile::class);
|
||||
}
|
||||
$type = new InputFile();
|
||||
TypeRegistry::set(InputFile::class, $type);
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user