mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-22 12:56:05 +03:00
Merge branch 'master' of https://github.com/webonyx/graphql-php
This commit is contained in:
commit
b141ed2d72
@ -67,7 +67,7 @@ class OperationParams
|
|||||||
'queryid' => null,
|
'queryid' => null,
|
||||||
'documentid' => null, // alias to queryid
|
'documentid' => null, // alias to queryid
|
||||||
'id' => null, // alias to queryid
|
'id' => null, // alias to queryid
|
||||||
'operation' => null,
|
'operationname' => null,
|
||||||
'variables' => null
|
'variables' => null
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class OperationParams
|
|||||||
|
|
||||||
$instance->query = $params['query'];
|
$instance->query = $params['query'];
|
||||||
$instance->queryId = $params['queryid'] ?: $params['documentid'] ?: $params['id'];
|
$instance->queryId = $params['queryid'] ?: $params['documentid'] ?: $params['id'];
|
||||||
$instance->operation = $params['operation'];
|
$instance->operation = $params['operationname'];
|
||||||
$instance->variables = $params['variables'];
|
$instance->variables = $params['variables'];
|
||||||
$instance->readOnly = (bool) $readonly;
|
$instance->readOnly = (bool) $readonly;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$post = [
|
$post = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'variables' => $variables,
|
'variables' => $variables,
|
||||||
'operation' => $operation
|
'operationName' => $operation
|
||||||
];
|
];
|
||||||
$parsed = [
|
$parsed = [
|
||||||
'raw' => $this->parseRawFormUrlencodedRequest($post),
|
'raw' => $this->parseRawFormUrlencodedRequest($post),
|
||||||
@ -56,7 +56,7 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$get = [
|
$get = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'variables' => $variables,
|
'variables' => $variables,
|
||||||
'operation' => $operation
|
'operationName' => $operation
|
||||||
];
|
];
|
||||||
$parsed = [
|
$parsed = [
|
||||||
'raw' => $this->parseRawGetRequest($get),
|
'raw' => $this->parseRawGetRequest($get),
|
||||||
@ -78,7 +78,7 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$body = [
|
$body = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'variables' => $variables,
|
'variables' => $variables,
|
||||||
'operation' => $operation
|
'operationName' => $operation
|
||||||
];
|
];
|
||||||
$parsed = [
|
$parsed = [
|
||||||
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
||||||
@ -99,7 +99,7 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$body = [
|
$body = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'variables' => json_encode($variables),
|
'variables' => json_encode($variables),
|
||||||
'operation' => $operation
|
'operationName' => $operation
|
||||||
];
|
];
|
||||||
$parsed = [
|
$parsed = [
|
||||||
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
||||||
@ -120,7 +120,7 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
$body = [
|
$body = [
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'variables' => $variables,
|
'variables' => $variables,
|
||||||
'operation' => $operation
|
'operationName' => $operation
|
||||||
];
|
];
|
||||||
$parsed = [
|
$parsed = [
|
||||||
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
'raw' => $this->parseRawRequest('application/json', json_encode($body)),
|
||||||
@ -138,12 +138,12 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
[
|
[
|
||||||
'query' => '{my query}',
|
'query' => '{my query}',
|
||||||
'variables' => ['test' => 1, 'test2' => 2],
|
'variables' => ['test' => 1, 'test2' => 2],
|
||||||
'operation' => 'op'
|
'operationName' => 'op'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'queryId' => 'my-query-id',
|
'queryId' => 'my-query-id',
|
||||||
'variables' => ['test' => 1, 'test2' => 2],
|
'variables' => ['test' => 1, 'test2' => 2],
|
||||||
'operation' => 'op2'
|
'operationName' => 'op2'
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$parsed = [
|
$parsed = [
|
||||||
@ -153,8 +153,8 @@ class RequestParsingTest extends \PHPUnit_Framework_TestCase
|
|||||||
foreach ($parsed as $method => $parsedBody) {
|
foreach ($parsed as $method => $parsedBody) {
|
||||||
$this->assertInternalType('array', $parsedBody, $method);
|
$this->assertInternalType('array', $parsedBody, $method);
|
||||||
$this->assertCount(2, $parsedBody, $method);
|
$this->assertCount(2, $parsedBody, $method);
|
||||||
$this->assertValidOperationParams($parsedBody[0], $body[0]['query'], null, $body[0]['variables'], $body[0]['operation'], $method);
|
$this->assertValidOperationParams($parsedBody[0], $body[0]['query'], null, $body[0]['variables'], $body[0]['operationName'], $method);
|
||||||
$this->assertValidOperationParams($parsedBody[1], null, $body[1]['queryId'], $body[1]['variables'], $body[1]['operation'], $method);
|
$this->assertValidOperationParams($parsedBody[1], null, $body[1]['queryId'], $body[1]['variables'], $body[1]['operationName'], $method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class RequestValidationTest extends \PHPUnit_Framework_TestCase
|
|||||||
$parsedBody = OperationParams::create([
|
$parsedBody = OperationParams::create([
|
||||||
'query' => $query,
|
'query' => $query,
|
||||||
'variables' => $variables,
|
'variables' => $variables,
|
||||||
'operation' => $operation,
|
'operationName' => $operation,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertValid($parsedBody);
|
$this->assertValid($parsedBody);
|
||||||
@ -30,7 +30,7 @@ class RequestValidationTest extends \PHPUnit_Framework_TestCase
|
|||||||
$parsedBody = OperationParams::create([
|
$parsedBody = OperationParams::create([
|
||||||
'queryId' => $queryId,
|
'queryId' => $queryId,
|
||||||
'variables' => $variables,
|
'variables' => $variables,
|
||||||
'operation' => $operation,
|
'operationName' => $operation,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertValid($parsedBody);
|
$this->assertValid($parsedBody);
|
||||||
@ -40,7 +40,7 @@ class RequestValidationTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$parsedBody = OperationParams::create([
|
$parsedBody = OperationParams::create([
|
||||||
'variables' => ['foo' => 'bar'],
|
'variables' => ['foo' => 'bar'],
|
||||||
'operation' => 'op',
|
'operationName' => 'op',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertInputError(
|
$this->assertInputError(
|
||||||
@ -90,7 +90,7 @@ class RequestValidationTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$parsedBody = OperationParams::create([
|
$parsedBody = OperationParams::create([
|
||||||
'query' => '{my query}',
|
'query' => '{my query}',
|
||||||
'operation' => []
|
'operationName' => []
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->assertInputError(
|
$this->assertInputError(
|
||||||
|
@ -57,6 +57,23 @@ class StandardServerTest extends TestCase
|
|||||||
$this->assertPsrRequestEquals($expected, $request);
|
$this->assertPsrRequestEquals($expected, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMultipleOperationPsrRequestExecution()
|
||||||
|
{
|
||||||
|
$body = [
|
||||||
|
'query' => 'query firstOp {fieldWithPhpError} query secondOp {f1}',
|
||||||
|
'operationName' => 'secondOp'
|
||||||
|
];
|
||||||
|
|
||||||
|
$expected = [
|
||||||
|
'data' => [
|
||||||
|
'f1' => 'f1'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$request = $this->preparePsrRequest('application/json', $body);
|
||||||
|
$this->assertPsrRequestEquals($expected, $request);
|
||||||
|
}
|
||||||
|
|
||||||
private function executePsrRequest($psrRequest)
|
private function executePsrRequest($psrRequest)
|
||||||
{
|
{
|
||||||
$server = new StandardServer($this->config);
|
$server = new StandardServer($this->config);
|
||||||
|
Loading…
Reference in New Issue
Block a user