From 7d248f29f026d12c1be14e1de5090adba41c799d Mon Sep 17 00:00:00 2001 From: Binyamin Yawitz <316103+byawitz@users.noreply.github.com> Date: Tue, 11 Jun 2024 18:08:40 -0400 Subject: [PATCH] feat: Coroutine graphql wip --- app/controllers/api/graphql.php | 1 - app/controllers/shared/api/auth.php | 4 ++++ composer.lock | 8 ++++---- src/Appwrite/GraphQL/Resolvers.php | 12 ++++++------ 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index a9bd5dd1eb..0e7ddc783d 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -157,7 +157,6 @@ Http::post('/v1/graphql') if (\str_starts_with($type, 'multipart/form-data')) { $query = parseMultipart($query, $request); } - $output = execute($schema, $promiseAdapter, $query); $response diff --git a/app/controllers/shared/api/auth.php b/app/controllers/shared/api/auth.php index 2d676e16b5..b5ccc36d28 100644 --- a/app/controllers/shared/api/auth.php +++ b/app/controllers/shared/api/auth.php @@ -55,6 +55,10 @@ Http::init() return; } + if(str_contains($route->getPath(), '/v1/graphql')) { // Skip for graphQL recursive call + return; + } + $auths = $project->getAttribute('auths', []); switch ($route->getLabel('auth.type', '')) { case 'emailPassword': diff --git a/composer.lock b/composer.lock index 1adfe7ef0c..72b2b0405d 100644 --- a/composer.lock +++ b/composer.lock @@ -1991,12 +1991,12 @@ "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "f54000a0f47b6eea34a373212711729b336a56bc" + "reference": "bf2474554f78d870c74aaaa1dfb4f54795ae9497" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/f54000a0f47b6eea34a373212711729b336a56bc", - "reference": "f54000a0f47b6eea34a373212711729b336a56bc", + "url": "https://api.github.com/repos/utopia-php/http/zipball/bf2474554f78d870c74aaaa1dfb4f54795ae9497", + "reference": "bf2474554f78d870c74aaaa1dfb4f54795ae9497", "shasum": "" }, "require": { @@ -2033,7 +2033,7 @@ "issues": "https://github.com/utopia-php/http/issues", "source": "https://github.com/utopia-php/http/tree/feat-di-upgrade" }, - "time": "2024-06-11T16:03:46+00:00" + "time": "2024-06-11T16:38:45+00:00" }, { "name": "utopia-php/image", diff --git a/src/Appwrite/GraphQL/Resolvers.php b/src/Appwrite/GraphQL/Resolvers.php index 65365eb269..9ce0de4735 100644 --- a/src/Appwrite/GraphQL/Resolvers.php +++ b/src/Appwrite/GraphQL/Resolvers.php @@ -30,7 +30,7 @@ class Resolvers UtopiaHttpResponse $response, Container $container, ): callable { - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $route, $args, $context, $container, $info, $request, $response) { $path = $route->getPath(); foreach ($args as $key => $value) { @@ -96,7 +96,7 @@ class Resolvers Container $container, ): callable { $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('GET'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -127,7 +127,7 @@ class Resolvers Container $container, ): callable { $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $params, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('GET'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -163,7 +163,7 @@ class Resolvers Container $container, ): callable { $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $params, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('POST'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -195,7 +195,7 @@ class Resolvers Container $container, ): callable { $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $params, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('PATCH'); $request->setURI($url($databaseId, $collectionId, $args)); @@ -225,7 +225,7 @@ class Resolvers Container $container, ): callable { $resolver = $this; - return fn($type, $args, $context, $info) => new Swoole( + return fn ($type, $args, $context, $info) => new Swoole( function (callable $resolve, callable $reject) use ($http, $databaseId, $collectionId, $url, $type, $args, $container, $request, $response, $resolver) { $request->setMethod('DELETE'); $request->setURI($url($databaseId, $collectionId, $args));