1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00

Move custom types to their own class

This commit is contained in:
Jake Barnby 2022-09-30 19:51:27 +13:00
parent df651c3c78
commit f1429e8155
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 40 additions and 28 deletions

View file

@ -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;
}
}

View 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;
}
}