1
0
Fork 0
mirror of synced 2024-06-28 19:20:25 +12:00

Encode get query params for test

This commit is contained in:
Jake Barnby 2022-07-19 13:41:31 +12:00
parent d3565b673e
commit 37c832134b
2 changed files with 15 additions and 8 deletions

View file

@ -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
));

View file

@ -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',