diff --git a/app/controllers/api/graphql.php b/app/controllers/api/graphql.php index 5ff0336236..191e8fcfcf 100644 --- a/app/controllers/api/graphql.php +++ b/app/controllers/api/graphql.php @@ -76,9 +76,17 @@ App::post('/v1/graphql/upload') ->inject('schema') ->action(Closure::fromCallable('graphqlRequest')); + /** + * Execute a GraphQL request + * + * @param array $query + * @param Request $request + * @param Response $response + * @param CoroutinePromiseAdapter $promiseAdapter + * @param Type\Schema $schema + * @return void * @throws Exception - * @throws \Exception */ function graphqlRequest( array $query, @@ -141,7 +149,7 @@ function graphqlRequest( $promiseAdapter->all($promises)->then( function (array $results) use (&$output, &$wg, $debugFlags) { try { - processResult($results, $output, $debugFlags); + $output = processResult($results, $debugFlags); } finally { $wg->done(); } @@ -196,16 +204,15 @@ function parseMultipartRequest(array $query, Request $request): array * Process an array of results for output * * @param $result - * @param $output * @param $debugFlags - * @return void + * @return array */ -function processResult($result, &$output, $debugFlags): void +function processResult($result, $debugFlags): array { if (!isset($result[1])) { - $output = $result[0]->toArray($debugFlags); + return $result[0]->toArray($debugFlags); } else { - $output = \array_merge_recursive(...\array_map( + return \array_merge_recursive(...\array_map( static fn ($item) => $item->toArray($debugFlags), $result )); diff --git a/tests/e2e/Services/GraphQL/GraphQLLocalizationTest.php b/tests/e2e/Services/GraphQL/GraphQLLocalizationTest.php index f81528ede2..6179a0a879 100644 --- a/tests/e2e/Services/GraphQL/GraphQLLocalizationTest.php +++ b/tests/e2e/Services/GraphQL/GraphQLLocalizationTest.php @@ -16,7 +16,7 @@ class GraphQLLocalizationTest extends Scope public function testGetLocale(): array { $projectId = $this->getProject()['$id']; - $query = $this->getQuery(self::$GET_LOCALE); + $query = \urlencode($this->getQuery(self::$GET_LOCALE)); $locale = $this->client->call(Client::METHOD_GET, '/graphql?query=' . $query, \array_merge([ 'content-type' => 'application/json',