mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-28 15:56:02 +03:00
Merge pull request #418 from Quartz/improvement/apollo-compatible-persisted-queries
Allow extensions to be provided in GET request.
This commit is contained in:
commit
5ac3eeab18
@ -89,11 +89,18 @@ class OperationParams
|
||||
$params['variables'] = null;
|
||||
}
|
||||
|
||||
if (is_string($params['variables'])) {
|
||||
$tmp = json_decode($params['variables'], true);
|
||||
if (! json_last_error()) {
|
||||
$params['variables'] = $tmp;
|
||||
// Some parameters could be provided as serialized JSON.
|
||||
foreach (['extensions', 'variables'] as $param) {
|
||||
if (! is_string($params[$param])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$tmp = json_decode($params[$param], true);
|
||||
if (json_last_error()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$params[$param] = $tmp;
|
||||
}
|
||||
|
||||
$instance->query = $params['query'];
|
||||
|
@ -293,14 +293,16 @@ class RequestParsingTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function testParsesVariablesAsJSON() : void
|
||||
public function testParsesParamsAsJSON() : void
|
||||
{
|
||||
$query = '{my query}';
|
||||
$variables = ['test' => 1, 'test2' => 2];
|
||||
$operation = 'op';
|
||||
$query = '{my query}';
|
||||
$variables = ['test1' => 1, 'test2' => 2];
|
||||
$extensions = ['test3' => 3, 'test4' => 4];
|
||||
$operation = 'op';
|
||||
|
||||
$body = [
|
||||
'query' => $query,
|
||||
'extensions' => json_encode($extensions),
|
||||
'variables' => json_encode($variables),
|
||||
'operationName' => $operation,
|
||||
];
|
||||
@ -309,7 +311,7 @@ class RequestParsingTest extends TestCase
|
||||
'psr' => $this->parsePsrRequest('application/json', json_encode($body)),
|
||||
];
|
||||
foreach ($parsed as $method => $parsedBody) {
|
||||
self::assertValidOperationParams($parsedBody, $query, null, $variables, $operation, null, $method);
|
||||
self::assertValidOperationParams($parsedBody, $query, null, $variables, $operation, $extensions, $method);
|
||||
self::assertFalse($parsedBody->isReadOnly(), $method);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user