1
0
Fork 0
mirror of synced 2024-10-01 01:37:56 +13:00

Format and lint

This commit is contained in:
Jake Barnby 2022-07-12 09:52:00 +12:00
parent 7259f21cf1
commit 10a5c24a63
13 changed files with 25 additions and 86 deletions

View file

@ -1010,4 +1010,3 @@ App::setResource('promiseAdapter', function ($register) {
App::setResource('gqlSchema', function ($utopia, $dbForProject, $user) {
return Builder::buildSchema($utopia, $dbForProject, $user);
}, ['utopia', 'dbForProject', 'user']);

View file

@ -29,7 +29,7 @@ use Utopia\WebSocket\Adapter;
require_once __DIR__ . '/init.php';
Runtime::enableCoroutine(true,SWOOLE_HOOK_ALL);
Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL);
$realtime = new Realtime();

View file

@ -172,7 +172,7 @@ class Exception extends \Exception
public const DOMAIN_VERIFICATION_FAILED = 'domain_verification_failed';
/** GraphqQL */
const GRAPHQL_NO_QUERY = 'graphql_no_query';
public const GRAPHQL_NO_QUERY = 'graphql_no_query';
private $type = '';

View file

@ -3,6 +3,7 @@
namespace Appwrite\GraphQL;
use Swoole\Coroutine\Channel;
use function Co\go;
/**
@ -12,9 +13,9 @@ use function Co\go;
*/
class CoroutinePromise
{
const STATE_PENDING = 1;
const STATE_FULFILLED = 0;
const STATE_REJECTED = -1;
protected const STATE_PENDING = 1;
protected const STATE_FULFILLED = 0;
protected const STATE_REJECTED = -1;
protected int $state = self::STATE_PENDING;
@ -235,4 +236,4 @@ class CoroutinePromise
{
return $this->state == self::STATE_REJECTED;
}
}
}

View file

@ -7,6 +7,7 @@ use GraphQL\Executor\Promise\Promise;
use GraphQL\Executor\Promise\PromiseAdapter;
use GraphQL\Utils\Utils;
use Swoole\Coroutine\Channel;
use function Co\go;
class CoroutinePromiseAdapter implements PromiseAdapter
@ -35,7 +36,7 @@ class CoroutinePromiseAdapter implements PromiseAdapter
public function create(callable $resolver): Promise
{
$promise = new CoroutinePromise(function($resolve, $reject) use($resolver) {
$promise = new CoroutinePromise(function ($resolve, $reject) use ($resolver) {
$resolver($resolve, $reject);
});
@ -44,7 +45,7 @@ class CoroutinePromiseAdapter implements PromiseAdapter
public function createFulfilled($value = null): Promise
{
$promise = new CoroutinePromise(function($resolve, $reject) use($value) {
$promise = new CoroutinePromise(function ($resolve, $reject) use ($value) {
$resolve($value);
});
@ -101,4 +102,4 @@ class CoroutinePromiseAdapter implements PromiseAdapter
return new Promise($all, $this);
}
}
}

View file

@ -16,4 +16,4 @@ class GQLException extends Exception implements ClientAware
{
return 'appwrite';
}
}
}

View file

@ -1,56 +0,0 @@
<?php
namespace Appwrite\GraphQL;
use GraphQL\Error\ClientAware;
class GQLExceptionDev extends \Exception implements ClientAware
{
private string $version;
private array $trace;
function __construct(
string $message = '',
int $code = 0,
string $version = '',
string $file = '',
int $line = -1,
array $trace = []
)
{
parent::__construct($message, $code);
$this->message = $message;
$this->code = $code;
$this->version = $version;
$this->file = $file;
$this->line = $line;
$this->trace = $trace;
}
public function isClientSafe(): bool
{
return true;
}
public function getCategory(): string
{
return 'Appwrite Server Exception';
}
/**
* @return string
*/
public function getVersion(): string
{
return $this->version;
}
/**
* @param string $version
*/
public function setVersion(string $version): void
{
$this->version = $version;
}
}

View file

@ -58,4 +58,4 @@ class InputFile extends ScalarType
{
throw new Error('`InputFile` cannot be hardcoded in query, be sure to conform to GraphQL multipart request specification. Instead got: ' . $valueNode->kind, $valueNode);
}
}
}

View file

@ -193,9 +193,6 @@ class Response extends SwooleResponse
// Tests (keep last)
public const MODEL_MOCK = 'mock';
// Content type
const CONTENT_TYPE_NULL = 'null';
/**
* @var Filter
*/
@ -325,6 +322,7 @@ class Response extends SwooleResponse
* HTTP content types
*/
public const CONTENT_TYPE_YAML = 'application/x-yaml';
public const CONTENT_TYPE_NULL = 'null';
/**
* List of defined output objects
@ -368,9 +366,9 @@ class Response extends SwooleResponse
}
/**
* Returns the model that was used to
* Returns the model that was used to
* parse the currrent payload
*
*
* @return string
*/
public function getCurrentModel(): string
@ -396,19 +394,19 @@ class Response extends SwooleResponse
$output = self::getFilter()->parse($output, $model);
}
switch($this->getContentType()) {
switch ($this->getContentType()) {
case self::CONTENT_TYPE_JSON:
$this->json(!empty($output) ? $output : new stdClass());
break;
case self::CONTENT_TYPE_YAML:
$this->yaml(!empty($output) ? $output : new stdClass());
break;
case self::CONTENT_TYPE_NULL:
break;
default :
default:
if ($model === self::MODEL_NONE) {
$this->noContent();
} else {
@ -554,5 +552,4 @@ class Response extends SwooleResponse
{
return self::$filter != null;
}
}

View file

@ -77,4 +77,4 @@ class Document extends Any
return $document;
}
}
}

View file

@ -259,4 +259,4 @@ class GraphQLTeamsServerTest extends Scope
$this->assertEquals(200, $team['headers']['status-code']);
}
}
}

View file

@ -419,4 +419,4 @@ class GraphQLUsersTest extends Scope
$this->assertEquals(204, $user['headers']['status-code']);
}
}
}

View file

@ -12,8 +12,6 @@ use Utopia\App;
class BuilderTest extends TestCase
{
/**
* @var Response
*/
@ -25,10 +23,9 @@ class BuilderTest extends TestCase
Builder::init();
}
public function testCreateTypeMapping()
public function testCreateTypeMapping()
{
$model = $this->response->getModel(Response::MODEL_COLLECTION);
$typeMapping = Builder::getModelTypeMapping($model, $this->response);
}
}
}