Skip to content

Commit d193913

Browse files
committed
229: [GraphQL caching] Add support for queries via HTTP GET
1 parent b3402d7 commit d193913

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQl/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,14 @@ public function postQuery(string $query, array $variables = [], string $operatio
6666
$responseBodyArray = $this->json->jsonDecode($responseBody);
6767

6868
if (!is_array($responseBodyArray)) {
69+
//phpcs:ignore Magento2.Exceptions.DirectThrow
6970
throw new \Exception('Unknown GraphQL response body: ' . json_encode($responseBodyArray));
7071
}
7172

7273
$this->processErrors($responseBodyArray);
7374

7475
if (!isset($responseBodyArray['data'])) {
76+
//phpcs:ignore Magento2.Exceptions.DirectThrow
7577
throw new \Exception('Unknown GraphQL response body: ' . json_encode($responseBodyArray));
7678
} else {
7779
return $responseBodyArray['data'];
@@ -101,12 +103,14 @@ public function getQuery(string $query, array $variables = [], string $operation
101103
$responseBodyArray = $this->json->jsonDecode($responseBody);
102104

103105
if (!is_array($responseBodyArray)) {
106+
//phpcs:ignore Magento2.Exceptions.DirectThrow
104107
throw new \Exception('Unknown GraphQL response body: ' . json_encode($responseBodyArray));
105108
}
106109

107110
$this->processErrors($responseBodyArray);
108111

109112
if (!isset($responseBodyArray['data'])) {
113+
//phpcs:ignore Magento2.Exceptions.DirectThrow
110114
throw new \Exception('Unknown GraphQL response body: ' . json_encode($responseBodyArray));
111115
} else {
112116
return $responseBodyArray['data'];
@@ -142,6 +146,7 @@ private function processErrors($responseBodyArray)
142146
$responseBodyArray
143147
);
144148
}
149+
//phpcs:ignore Magento2.Exceptions.DirectThrow
145150
throw new \Exception('GraphQL responded with an unknown error: ' . json_encode($responseBodyArray));
146151
}
147152
}

dev/tests/api-functional/framework/Magento/TestFramework/TestCase/GraphQlAbstract.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function graphQlQuery(
6161
$this->composeHeaders($headers)
6262
);
6363
} else {
64+
//phpcs:ignore Magento2.Exceptions.DirectThrow
6465
throw new \Exception("Unsupported request type");
6566
}
6667

dev/tests/integration/testsuite/Magento/Framework/GraphQl/Config/GraphQlReaderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ protected function setUp()
4545
\Magento\Framework\Config\FileResolverInterface::class
4646
)->disableOriginalConstructor()->getMock();
4747
$fileList = [
48+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
4849
file_get_contents(__DIR__ . '/../_files/schemaA.graphqls'),
50+
//phpcs:ignore Magento2.Functions.DiscouragedFunction
4951
file_get_contents(__DIR__ . '/../_files/schemaB.graphqls')
5052
];
5153
$fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($fileList));
@@ -185,7 +187,7 @@ enumValues(includeDeprecated: true) {
185187
$request->setHeaders($headers);
186188
$response = $this->graphQlController->dispatch($request);
187189
$output = $this->jsonSerializer->unserialize($response->getContent());
188-
//phpcs:ignore Magento2.Security.IncludeFile.FoundIncludeFile
190+
//phpcs:ignore Magento2.Security.IncludeFile
189191
$expectedOutput = require __DIR__ . '/../_files/schema_response_sdl_description.php';
190192

191193
$schemaResponseFields = $output['data']['__schema']['types'];

dev/tests/integration/testsuite/Magento/GraphQl/Controller/GraphQlControllerTest.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class GraphQlControllerTest extends \Magento\TestFramework\Indexer\TestCase
3838
/** @var MetadataPool */
3939
private $metadataPool;
4040

41+
//phpcs:ignore Magento2.Functions.StaticFunction
4142
public static function setUpBeforeClass()
4243
{
4344
$db = Bootstrap::getInstance()->getBootstrap()
@@ -265,12 +266,4 @@ public function testError() : void
265266
}
266267
}
267268
}
268-
269-
/**
270-
* teardown
271-
*/
272-
public function tearDown()
273-
{
274-
parent::tearDown();
275-
}
276269
}

0 commit comments

Comments
 (0)