mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
Apollo server/client compatibility. Look for queryid in extensions.
This commit is contained in:
parent
b2cea8b538
commit
63b4e3f0a4
@ -95,6 +95,11 @@ class OperationParams
|
|||||||
$instance->variables = $params['variables'];
|
$instance->variables = $params['variables'];
|
||||||
$instance->readOnly = (bool) $readonly;
|
$instance->readOnly = (bool) $readonly;
|
||||||
|
|
||||||
|
// Apollo server/client compatibility: look for the queryid in extensions
|
||||||
|
if (isset($params['extensions']['persistedQuery']['sha256Hash']) && empty($instance->query) && empty($instance->queryid)) {
|
||||||
|
$instance->queryId = $params['extensions']['persistedQuery']['sha256Hash'];
|
||||||
|
}
|
||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,6 +333,32 @@ class RequestParsingTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParsesApolloPersistedQueryJSONRequest() : void
|
||||||
|
{
|
||||||
|
$queryId = 'my-query-id';
|
||||||
|
$extensions = [
|
||||||
|
'persistedQuery' => [
|
||||||
|
'sha256Hash' => $queryId,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$variables = ['test' => 1, 'test2' => 2];
|
||||||
|
$operation = 'op';
|
||||||
|
|
||||||
|
$body = [
|
||||||
|
'extensions' => $extensions,
|
||||||
|
'variables' => $variables,
|
||||||
|
'operationName' => $operation,
|
||||||
|
];
|
||||||
|
$parsed = [
|
||||||
|
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
||||||
|
'psr' => $this->parsePsrRequest('application/json', json_encode($body)),
|
||||||
|
];
|
||||||
|
foreach ($parsed as $method => $parsedBody) {
|
||||||
|
self::assertValidOperationParams($parsedBody, null, $queryId, $variables, $operation, $method);
|
||||||
|
self::assertFalse($parsedBody->isReadOnly(), $method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testParsesBatchJSONRequest() : void
|
public function testParsesBatchJSONRequest() : void
|
||||||
{
|
{
|
||||||
$body = [
|
$body = [
|
||||||
|
Loading…
Reference in New Issue
Block a user