Skip to content

Commit a182f92

Browse files
committed
Revert "Merge branch 'lynx-319' of github.com:sivaschenko/magento2ce into LYNX-311-DELIVERY"
This reverts commit 676a315, reversing changes made to ad7dfa8.
1 parent 6d83d00 commit a182f92

File tree

7 files changed

+11
-344
lines changed

7 files changed

+11
-344
lines changed

app/code/Magento/CustomerGraphQl/Controller/HttpRequestValidator/AuthorizationRequestValidator.php

Lines changed: 0 additions & 80 deletions
This file was deleted.

app/code/Magento/CustomerGraphQl/etc/graphql/di.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,4 @@
214214
</argument>
215215
</arguments>
216216
</type>
217-
<type name="Magento\GraphQl\Controller\HttpRequestProcessor">
218-
<arguments>
219-
<argument name="requestValidators" xsi:type="array">
220-
<item name="authorizationValidator" xsi:type="object">Magento\CustomerGraphQl\Controller\HttpRequestValidator\AuthorizationRequestValidator</item>
221-
</argument>
222-
</arguments>
223-
</type>
224217
</config>

app/code/Magento/GraphQl/Controller/GraphQl.php

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
use Magento\Framework\App\ResponseInterface;
2020
use Magento\Framework\Controller\Result\JsonFactory;
2121
use Magento\Framework\GraphQl\Exception\ExceptionFormatter;
22-
use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
23-
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
2422
use Magento\Framework\GraphQl\Query\Fields as QueryFields;
2523
use Magento\Framework\GraphQl\Query\QueryParser;
2624
use Magento\Framework\GraphQl\Query\QueryProcessor;
@@ -183,9 +181,10 @@ public function dispatch(RequestInterface $request): ResponseInterface
183181
{
184182
$this->areaList->getArea(Area::AREA_GRAPHQL)->load(Area::PART_TRANSLATE);
185183

184+
$statusCode = 200;
186185
$jsonResult = $this->jsonFactory->create();
187186
$data = $this->getDataFromRequest($request);
188-
$result = ['errors' => []];
187+
$result = [];
189188

190189
$schema = null;
191190
try {
@@ -206,14 +205,8 @@ public function dispatch(RequestInterface $request): ResponseInterface
206205
$this->contextFactory->create(),
207206
$data['variables'] ?? []
208207
);
209-
$statusCode = $this->getHttpResponseCode($result);
210-
} catch (GraphQlAuthenticationException $error) {
211-
$result['errors'][] = $this->graphQlError->create($error);
212-
$statusCode = 401;
213-
} catch (GraphQlAuthorizationException $error) {
214-
$result['errors'][] = $this->graphQlError->create($error);
215-
$statusCode = 403;
216208
} catch (\Exception $error) {
209+
$result['errors'] = isset($result['errors']) ? $result['errors'] : [];
217210
$result['errors'][] = $this->graphQlError->create($error);
218211
$statusCode = ExceptionFormatter::HTTP_GRAPH_QL_SCHEMA_ERROR_STATUS;
219212
}
@@ -231,32 +224,6 @@ public function dispatch(RequestInterface $request): ResponseInterface
231224
return $this->httpResponse;
232225
}
233226

234-
/**
235-
* Retrieve http response code based on the error categories
236-
*
237-
* @param array $result
238-
* @return int
239-
*/
240-
private function getHttpResponseCode(array $result): int
241-
{
242-
if (empty($result['errors'])) {
243-
return 200;
244-
}
245-
foreach ($result['errors'] as $error) {
246-
if (!isset($error['extensions']['category'])) {
247-
continue;
248-
}
249-
switch ($error['extensions']['category']) {
250-
case GraphQlAuthenticationException::EXCEPTION_CATEGORY:
251-
return 401;
252-
case GraphQlAuthorizationException::EXCEPTION_CATEGORY:
253-
return 403;
254-
}
255-
}
256-
257-
return 200;
258-
}
259-
260227
/**
261228
* Get data from request body or query string
262229
*

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/AuthenticationTest.php

Lines changed: 0 additions & 211 deletions
This file was deleted.

dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerGraphQl/Model/Resolver/CustomerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Magento\TestFramework\Fixture\DataFixture;
2727
use Magento\TestFramework\Helper\Bootstrap;
2828
use Magento\TestFramework\TestCase\GraphQl\ResolverCacheAbstract;
29+
use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException;
2930

3031
/**
3132
* Test for customer resolver cache
@@ -541,7 +542,7 @@ public function testGuestQueryingCustomerDoesNotGenerateResolverCacheEntry()
541542
$query
542543
);
543544
$this->fail('Expected exception not thrown');
544-
} catch (\Exception $e) {
545+
} catch (ResponseContainsErrorsException $e) {
545546
// expected exception
546547
}
547548

0 commit comments

Comments
 (0)