feat: support for delete mutation

This commit is contained in:
Christy Jacob 2021-03-18 02:47:50 +05:30
parent 99ade8ec13
commit 455ba3ff18
2 changed files with 8 additions and 6 deletions

View file

@ -31,7 +31,7 @@ class Builder {
Model::TYPE_INTEGER => Type::int(), Model::TYPE_INTEGER => Type::int(),
Model::TYPE_FLOAT => Type::float(), Model::TYPE_FLOAT => Type::float(),
Model::TYPE_JSON => self::json(), Model::TYPE_JSON => self::json(),
Response::MODEL_NONE => Type::string(), Response::MODEL_NONE => self::json(),
Response::MODEL_ANY => self::json(), Response::MODEL_ANY => self::json(),
]; ];
} }
@ -202,7 +202,6 @@ class Builder {
} }
return $args; return $args;
} }
/** /**
* This function goes through all the REST endpoints in the API and builds a * This function goes through all the REST endpoints in the API and builds a
@ -226,7 +225,7 @@ class Builder {
$namespace = $route->getLabel('sdk.namespace', ''); $namespace = $route->getLabel('sdk.namespace', '');
$methodName = $namespace.'_'.$route->getLabel('sdk.method', ''); $methodName = $namespace.'_'.$route->getLabel('sdk.method', '');
$responseModelName = $route->getLabel('sdk.response.model', ""); $responseModelName = $route->getLabel('sdk.response.model', "");
if ( $responseModelName !== "" && $responseModelName !== Response::MODEL_NONE ) { if ( $responseModelName !== "" ) {
$responseModel = $response->getModel($responseModelName); $responseModel = $response->getModel($responseModelName);
$type = self::getTypeMapping($responseModel, $response); $type = self::getTypeMapping($responseModel, $response);
$description = $route->getDesc(); $description = $route->getDesc();
@ -237,10 +236,8 @@ class Builder {
$response = $register->get('__response'); $response = $register->get('__response');
$result = $response->getPayload(); $result = $response->getPayload();
if ( $response->getCurrentModel() == Response::MODEL_ERROR_DEV ) { if ( $response->getCurrentModel() == Response::MODEL_ERROR_DEV ) {
var_dump("***** There has been an dev exception.. *****");
throw new ExceptionDev($result['message'], $result['code'], $result['version'], $result['file'], $result['line'], $result['trace']); throw new ExceptionDev($result['message'], $result['code'], $result['version'], $result['file'], $result['line'], $result['trace']);
} else if ( $response->getCurrentModel() == Response::MODEL_ERROR ) { } else if ( $response->getCurrentModel() == Response::MODEL_ERROR ) {
var_dump("***** There has been an exception.. *****");
throw new Exception($result['message'], $result['code']); throw new Exception($result['message'], $result['code']);
} }
return $result; return $result;

View file

@ -319,7 +319,7 @@ class Response extends SwooleResponse
$this->model = $model->getType(); $this->model = $model->getType();
if ($model->isAny()) { if ($model->isAny() || $model->isNone()) {
$this->payload = $document->getArrayCopy(); $this->payload = $document->getArrayCopy();
return $this->payload; return $this->payload;
} }
@ -421,4 +421,9 @@ class Response extends SwooleResponse
{ {
return self::$filter != null; return self::$filter != null;
} }
public function noContent(): void
{
$this->output(new Document(), self::MODEL_NONE);
}
} }