From d95a1b277f0cc81f4568825bf49c7633064930bb Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 8 Apr 2022 19:16:35 +1200 Subject: [PATCH] Expose swoole request instead of stealing it --- src/Appwrite/GraphQL/Builder.php | 8 +++----- src/Appwrite/Utopia/Request.php | 5 +++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/GraphQL/Builder.php b/src/Appwrite/GraphQL/Builder.php index bd1198b228..f2e99f654c 100644 --- a/src/Appwrite/GraphQL/Builder.php +++ b/src/Appwrite/GraphQL/Builder.php @@ -385,7 +385,7 @@ class Builder $wg->wait(); $time_elapsed_secs = (microtime(true) - $start) * 1000; - Console::info("[INFO] Time Taken To Build REST API Schema : ${time_elapsed_secs}ms"); + Console::info("Built GraphQL Project Collection Schema in ${time_elapsed_secs}ms"); return [ 'query' => $queryFields, @@ -511,13 +511,11 @@ class Builder ]; } - /* Define a resolve function that defines how to fetch data for this type */ $resolve = fn($type, $args, $context, $info) => new CoroutinePromise( function (callable $resolve, callable $reject) use ($utopia, $request, $response, &$register, $route, $args) { // Mutate the original request object to include the query variables at the top level - $swooleRq = (fn() => $this->swoole)->bindTo($request, $request)(); + $swooleRq = $request->getSwoole(); $swooleRq->post = $args; - // Drop json content type so post args are used directly if ($swooleRq->header['content-type'] === 'application/json') { unset($swooleRq->header['content-type']); @@ -557,7 +555,7 @@ class Builder } $time_elapsed_secs = (microtime(true) - $start) * 1000; - Console::info("[INFO] Time Taken To Build REST API Schema : ${time_elapsed_secs}ms"); + Console::info("[INFO] Built GraphQL REST API Schema in ${time_elapsed_secs}ms"); return [ 'query' => $queryFields, diff --git a/src/Appwrite/Utopia/Request.php b/src/Appwrite/Utopia/Request.php index d6ad3d8a85..ce3bee1c5a 100644 --- a/src/Appwrite/Utopia/Request.php +++ b/src/Appwrite/Utopia/Request.php @@ -28,6 +28,11 @@ class Request extends UtopiaRequest parent::__construct($request); } + public function getSwoole(): SwooleRequest + { + return $this->swoole; + } + /** * Get Params *