diff --git a/src/Adapter/Swoole.php b/src/Adapter/Swoole.php index 11b4dae..3df1c6b 100644 --- a/src/Adapter/Swoole.php +++ b/src/Adapter/Swoole.php @@ -15,6 +15,8 @@ use Utopia\Fetch\Options\Swoole as SwooleOptions; use Utopia\Fetch\Response; +use function Swoole\Coroutine\run; + /** * Swoole Adapter * HTTP adapter using Swoole's HTTP client @@ -365,8 +367,7 @@ public function send( $response = null; $exception = null; - $coRun = 'Swoole\\Coroutine\\run'; - $coRun(function () use ($url, $method, $body, $headers, $options, $chunkCallback, &$response, &$exception) { + run(function () use ($url, $method, $body, $headers, $options, $chunkCallback, &$response, &$exception) { try { $response = $this->executeRequest($url, $method, $body, $headers, $options, $chunkCallback); } catch (Throwable $e) { diff --git a/src/Client.php b/src/Client.php index 67996b8..50ac37a 100644 --- a/src/Client.php +++ b/src/Client.php @@ -297,7 +297,7 @@ public function fetch( $body = match ($this->headers['content-type']) { self::CONTENT_TYPE_APPLICATION_JSON => $this->jsonEncode($body), self::CONTENT_TYPE_APPLICATION_FORM_URLENCODED, self::CONTENT_TYPE_MULTIPART_FORM_DATA => self::flatten($body), - self::CONTENT_TYPE_GRAPHQL => isset($body['query']) && is_string($body['query']) ? $body['query'] : throw new Exception('GraphQL body must contain a "query" field with a string value'), + self::CONTENT_TYPE_GRAPHQL => isset($body['query']) && is_string($body['query']) ? $body['query'] : $this->jsonEncode($body), default => $body, }; }