Refactoring
This commit is contained in:
parent
2eb024200e
commit
7319a1eeb9
5 changed files with 5997 additions and 6 deletions
|
@ -61,8 +61,10 @@ App::post('/v1/graphql')
|
|||
->inject('request')
|
||||
->inject('response')
|
||||
->inject('schema')
|
||||
->inject('utopia')
|
||||
->inject('register')
|
||||
->middleware(false)
|
||||
->action(function ($request, $response, $schema) {
|
||||
->action(function ($request, $response, $schema, $utopia, $register) {
|
||||
|
||||
// $myErrorFormatter = function(Error $error) {
|
||||
// $formattedError = FormattedError::createFromException($error);
|
||||
|
@ -73,6 +75,12 @@ App::post('/v1/graphql')
|
|||
$query = $request->getPayload('query', '');
|
||||
$variables = $request->getPayload('variables', null);
|
||||
$response->setContentType(Response::CONTENT_TYPE_NULL);
|
||||
$register->set('__app', function() use ($utopia) {
|
||||
return $utopia;
|
||||
});
|
||||
$register->set('__response', function() use ($response) {
|
||||
return $response;
|
||||
});
|
||||
|
||||
try {
|
||||
$rootValue = [];
|
||||
|
|
|
@ -516,7 +516,7 @@ App::setResource('schema', function($utopia, $response, $request, $register) {
|
|||
$schema = $register->get('_schema');
|
||||
} catch (Exception $e) {
|
||||
var_dump('[INFO] Exception, Schema not present. Generating Schema');
|
||||
$schema = GraphQLBuilder::buildSchema($utopia, $response, $request);
|
||||
$schema = GraphQLBuilder::buildSchema($utopia, $response, $register);
|
||||
$register->set('_schema', function () use ($schema){ // Register cache connection
|
||||
return $schema;
|
||||
});
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
"utopia-php/cli": "0.10.0",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/locale": "0.3.*",
|
||||
"utopia-php/registry": "0.2.*",
|
||||
"utopia-php/registry": "master",
|
||||
"utopia-php/preloader": "0.2.*",
|
||||
"utopia-php/domains": "0.2.*",
|
||||
"utopia-php/swoole": "0.2.*",
|
||||
|
|
5981
composer.lock
generated
Normal file
5981
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -196,7 +196,7 @@ class GraphQLBuilder {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function buildSchema($utopia, $response) {
|
||||
public static function buildSchema($utopia, $response, $register) {
|
||||
|
||||
self::init();
|
||||
|
||||
|
@ -228,14 +228,16 @@ class GraphQLBuilder {
|
|||
'type' => $type,
|
||||
'description' => $route->getDesc(),
|
||||
'args' => $args,
|
||||
'resolve' => function ($type, $args, $context, $info) use (&$utopia, $route, $response) {
|
||||
'resolve' => function ($type, $args, $context, $info) use (&$register, $route) {
|
||||
// var_dump("************* REACHED RESOLVE FOR {$info->fieldName} *****************");
|
||||
// var_dump($route);
|
||||
// var_dump("************* CONTEXT *****************");
|
||||
// var_dump($context);
|
||||
// var_dump("********************** ARGS *******************");
|
||||
// var_dump($args);
|
||||
|
||||
|
||||
$utopia = $register->get('__app');
|
||||
$response = $register->get('__response');
|
||||
$utopia->setRoute($route);
|
||||
$utopia->execute($route, $args);
|
||||
|
||||
|
|
Loading…
Reference in a new issue