Move custom types to their own class
This commit is contained in:
parent
df651c3c78
commit
f1429e8155
2 changed files with 40 additions and 28 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
40
src/Appwrite/GraphQL/Types.php
Normal file
40
src/Appwrite/GraphQL/Types.php
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue