feat: got locale_getContinents working
This commit is contained in:
parent
f378bcf48a
commit
f11e431341
|
@ -159,8 +159,6 @@ function getArgType(Validator $validator, bool $required) {
|
||||||
function getArgs(array $params) {
|
function getArgs(array $params) {
|
||||||
$args = [];
|
$args = [];
|
||||||
foreach ($params as $key => $value) {
|
foreach ($params as $key => $value) {
|
||||||
var_dump("Key : ${key}");
|
|
||||||
var_dump($value);
|
|
||||||
$args[$key] = [
|
$args[$key] = [
|
||||||
'type' => getArgType($value['validator'],!$value['optional']),
|
'type' => getArgType($value['validator'],!$value['optional']),
|
||||||
'description' => $value['description'],
|
'description' => $value['description'],
|
||||||
|
@ -183,22 +181,33 @@ function buildSchema($utopia, $response) {
|
||||||
$methodName = $namespace.'_'.$route->getLabel('sdk.method', '');
|
$methodName = $namespace.'_'.$route->getLabel('sdk.method', '');
|
||||||
$responseModelName = $route->getLabel('sdk.response.model', Response::MODEL_NONE);
|
$responseModelName = $route->getLabel('sdk.response.model', Response::MODEL_NONE);
|
||||||
|
|
||||||
var_dump("******************************************");
|
// var_dump("******************************************");
|
||||||
var_dump("Model Name : ${responseModelName}");
|
// var_dump("Model Name : ${responseModelName}");
|
||||||
|
|
||||||
if ( $responseModelName !== Response::MODEL_NONE && $responseModelName !== Response::MODEL_ANY ) {
|
if ( $responseModelName !== Response::MODEL_NONE && $responseModelName !== Response::MODEL_ANY ) {
|
||||||
$responseModel = $response->getModel($responseModelName);
|
$responseModel = $response->getModel($responseModelName);
|
||||||
createTypeMapping($responseModel, $response);
|
createTypeMapping($responseModel, $response);
|
||||||
|
|
||||||
|
$args = getArgs($route->getParams());
|
||||||
$fields[$methodName] = [
|
$fields[$methodName] = [
|
||||||
'type' => $typeMapping[$responseModel->getType()],
|
'type' => $typeMapping[$responseModel->getType()],
|
||||||
'description' => $route->getDesc(),
|
'description' => $route->getDesc(),
|
||||||
'args' => getArgs($route->getParams()),
|
'args' => $args,
|
||||||
|
'resolve' => function ($args) use (&$utopia, $route, $response) {
|
||||||
|
var_dump("************* REACHED RESOLVE *****************");
|
||||||
|
var_dump($route);
|
||||||
|
$utopia->execute($route, $args);
|
||||||
|
var_dump("********************** ARGS *******************");
|
||||||
|
var_dump($args);
|
||||||
|
var_dump("**************** OUTPUT ************");
|
||||||
|
var_dump($response->getPayload());
|
||||||
|
return $response->getPayload();
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
// print_r($fields[$methodName]);
|
// var_dump("Processed route : {$route->getURL()}");
|
||||||
var_dump("Processed route : {$route->getURL()}");
|
|
||||||
} else {
|
} else {
|
||||||
var_dump("Skipping route : {$route->getURL()}");
|
// var_dump("Skipping route : {$route->getURL()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,8 +241,7 @@ App::post('/v1/graphql')
|
||||||
->inject('request')
|
->inject('request')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('utopia')
|
->inject('utopia')
|
||||||
->inject('schema')
|
->action(function ($request, $response, $utopia) {
|
||||||
->action(function ($request, $response, $utopia, $schema) {
|
|
||||||
// Generate the Schema of the server on startup.
|
// Generate the Schema of the server on startup.
|
||||||
// Use the routes from utopia and get the params then construct the queries and mutations.
|
// Use the routes from utopia and get the params then construct the queries and mutations.
|
||||||
|
|
||||||
|
@ -246,6 +254,8 @@ App::post('/v1/graphql')
|
||||||
$rootValue = [];
|
$rootValue = [];
|
||||||
$result = GraphQL::executeQuery($schema, $query, $rootValue, null, $variables);
|
$result = GraphQL::executeQuery($schema, $query, $rootValue, null, $variables);
|
||||||
$output = $result->toArray();
|
$output = $result->toArray();
|
||||||
|
var_dump("********** OUTPUT *********");
|
||||||
|
var_dump($output);
|
||||||
} catch (\Exception $error) {
|
} catch (\Exception $error) {
|
||||||
$output = [
|
$output = [
|
||||||
'errors' => [
|
'errors' => [
|
||||||
|
|
|
@ -190,6 +190,8 @@ App::get('/v1/locale/continents')
|
||||||
/** @var Appwrite\Utopia\Response $response */
|
/** @var Appwrite\Utopia\Response $response */
|
||||||
/** @var Utopia\Locale\Locale $locale */
|
/** @var Utopia\Locale\Locale $locale */
|
||||||
|
|
||||||
|
var_dump("*************** IN LOCALE ************* ");
|
||||||
|
|
||||||
$list = $locale->getText('continents'); /* @var $list array */
|
$list = $locale->getText('continents'); /* @var $list array */
|
||||||
|
|
||||||
\asort($list);
|
\asort($list);
|
||||||
|
|
|
@ -47,9 +47,12 @@ App::init(function ($utopia, $request, $response, $project, $user, $register, $e
|
||||||
|
|
||||||
//TODO make sure we get array here
|
//TODO make sure we get array here
|
||||||
|
|
||||||
foreach ($request->getParams() as $key => $value) { // Set request params as potential abuse keys
|
|
||||||
$timeLimit->setParam('{param-'.$key.'}', (\is_array($value)) ? \json_encode($value) : $value);
|
var_dump($request->getParams());
|
||||||
}
|
|
||||||
|
// foreach ($request->getParams() as $key => $value) { // Set request params as potential abuse keys
|
||||||
|
// $timeLimit->setParam('{param-'.$key.'}', (\is_array($value)) ? \json_encode($value) : $value);
|
||||||
|
// }
|
||||||
|
|
||||||
$abuse = new Abuse($timeLimit);
|
$abuse = new Abuse($timeLimit);
|
||||||
|
|
||||||
|
|
|
@ -504,7 +504,7 @@ services:
|
||||||
graphiql:
|
graphiql:
|
||||||
container_name: graphiql
|
container_name: graphiql
|
||||||
ports:
|
ports:
|
||||||
- '9505:4000'
|
- '9506:4000'
|
||||||
environment:
|
environment:
|
||||||
- API_URL=http://localhost/v1/graphql
|
- API_URL=http://localhost/v1/graphql
|
||||||
image: npalm/graphiql
|
image: npalm/graphiql
|
||||||
|
|
|
@ -260,7 +260,7 @@ class Response extends SwooleResponse
|
||||||
$output = self::getFilter()->parse($output, $model);
|
$output = self::getFilter()->parse($output, $model);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->json(!empty($output) ? $output : new stdClass());
|
// $this->json(!empty($output) ? $output : new stdClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue