feat: refactor noContent()
This commit is contained in:
parent
455ba3ff18
commit
772f110eee
4 changed files with 25 additions and 10 deletions
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
use Appwrite\GraphQL\Builder;
|
||||
use GraphQL\GraphQL;
|
||||
use GraphQL\Type;
|
||||
use Appwrite\Utopia\Response;
|
||||
|
|
|
@ -550,5 +550,5 @@ App::delete('/v1/users/:userId')
|
|||
;
|
||||
|
||||
// TODO : Response filter implementation
|
||||
$response->noContent();
|
||||
$response->dynamic(new Document(), Response::MODEL_NONE);
|
||||
});
|
||||
|
|
|
@ -9,6 +9,9 @@ use GraphQL\Type\Definition\ObjectType;
|
|||
use GraphQL\Type\Definition\Type;
|
||||
use GraphQL\Type\Schema;
|
||||
use Appwrite\GraphQL\Exception;
|
||||
use GraphQL\Error\Error;
|
||||
use GraphQL\Error\FormattedError;
|
||||
use Utopia\App;
|
||||
|
||||
class Builder {
|
||||
|
||||
|
@ -279,4 +282,15 @@ class Builder {
|
|||
|
||||
return $schema;
|
||||
}
|
||||
|
||||
public static function errorFormatter(Error $error) {
|
||||
$formattedError = FormattedError::createFromException($error);
|
||||
var_dump("***** IN ERROR FORMATTER ******");
|
||||
$parentError = $error->getPrevious();
|
||||
$formattedError['code'] = $parentError->getCode();
|
||||
$formattedError['file'] = $parentError->getFile();
|
||||
$formattedError['version'] = App::getEnv('_APP_VERSION', 'UNKNOWN');
|
||||
$formattedError['line'] = $parentError->getLine();
|
||||
return $formattedError;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -281,7 +281,7 @@ class Response extends SwooleResponse
|
|||
$output = $this->output($document, $model);
|
||||
|
||||
// If filter is set, parse the output
|
||||
if(self::isFilter()){
|
||||
if(self::isFilter()) {
|
||||
$output = self::getFilter()->parse($output, $model);
|
||||
}
|
||||
|
||||
|
@ -289,16 +289,20 @@ class Response extends SwooleResponse
|
|||
case self::CONTENT_TYPE_JSON:
|
||||
$this->json(!empty($output) ? $output : new stdClass());
|
||||
break;
|
||||
|
||||
case self::CONTENT_TYPE_NULL:
|
||||
break;
|
||||
|
||||
case self::CONTENT_TYPE_YAML:
|
||||
$this->yaml(!empty($output) ? $output : new stdClass());
|
||||
break;
|
||||
|
||||
case self::CONTENT_TYPE_NULL:
|
||||
break;
|
||||
|
||||
default :
|
||||
$this->json(!empty($output) ? $output : new stdClass());
|
||||
if ($model === self::MODEL_NONE) {
|
||||
$this->noContent();
|
||||
} else {
|
||||
$this->json(!empty($output) ? $output : new stdClass());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -422,8 +426,4 @@ class Response extends SwooleResponse
|
|||
return self::$filter != null;
|
||||
}
|
||||
|
||||
public function noContent(): void
|
||||
{
|
||||
$this->output(new Document(), self::MODEL_NONE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue