Skip to content

Commit c6e1292

Browse files
authored
Merge pull request #18 from utopia-php/copilot/sub-pr-16
2 parents ae9cc01 + 632486c commit c6e1292

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

src/Adapter/Swoole.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Utopia\Fetch\Options\Swoole as SwooleOptions;
1616
use Utopia\Fetch\Response;
1717

18+
use function Swoole\Coroutine\run;
19+
1820
/**
1921
* Swoole Adapter
2022
* HTTP adapter using Swoole's HTTP client
@@ -365,8 +367,7 @@ public function send(
365367
$response = null;
366368
$exception = null;
367369

368-
$coRun = 'Swoole\\Coroutine\\run';
369-
$coRun(function () use ($url, $method, $body, $headers, $options, $chunkCallback, &$response, &$exception) {
370+
run(function () use ($url, $method, $body, $headers, $options, $chunkCallback, &$response, &$exception) {
370371
try {
371372
$response = $this->executeRequest($url, $method, $body, $headers, $options, $chunkCallback);
372373
} catch (Throwable $e) {

src/Client.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public function fetch(
297297
$body = match ($this->headers['content-type']) {
298298
self::CONTENT_TYPE_APPLICATION_JSON => $this->jsonEncode($body),
299299
self::CONTENT_TYPE_APPLICATION_FORM_URLENCODED, self::CONTENT_TYPE_MULTIPART_FORM_DATA => self::flatten($body),
300-
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'),
300+
self::CONTENT_TYPE_GRAPHQL => isset($body['query']) && is_string($body['query']) ? $body['query'] : $this->jsonEncode($body),
301301
default => $body,
302302
};
303303
}

0 commit comments

Comments
 (0)