Skip to content

Commit

Permalink
Revert "Merge branch 'lynx-319' of github.com:sivaschenko/magento2ce …
Browse files Browse the repository at this point in the history
…into LYNX-311-DELIVERY"

This reverts commit 676a315, reversing
changes made to ad7dfa8.
  • Loading branch information
svera committed Jan 22, 2024
1 parent 6d83d00 commit a182f92
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 344 deletions.

This file was deleted.

7 changes: 0 additions & 7 deletions app/code/Magento/CustomerGraphQl/etc/graphql/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,4 @@
</argument>
</arguments>
</type>
<type name="Magento\GraphQl\Controller\HttpRequestProcessor">
<arguments>
<argument name="requestValidators" xsi:type="array">
<item name="authorizationValidator" xsi:type="object">Magento\CustomerGraphQl\Controller\HttpRequestValidator\AuthorizationRequestValidator</item>
</argument>
</arguments>
</type>
</config>
39 changes: 3 additions & 36 deletions app/code/Magento/GraphQl/Controller/GraphQl.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\GraphQl\Exception\ExceptionFormatter;
use Magento\Framework\GraphQl\Exception\GraphQlAuthenticationException;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Query\Fields as QueryFields;
use Magento\Framework\GraphQl\Query\QueryParser;
use Magento\Framework\GraphQl\Query\QueryProcessor;
Expand Down Expand Up @@ -183,9 +181,10 @@ public function dispatch(RequestInterface $request): ResponseInterface
{
$this->areaList->getArea(Area::AREA_GRAPHQL)->load(Area::PART_TRANSLATE);

$statusCode = 200;
$jsonResult = $this->jsonFactory->create();
$data = $this->getDataFromRequest($request);
$result = ['errors' => []];
$result = [];

$schema = null;
try {
Expand All @@ -206,14 +205,8 @@ public function dispatch(RequestInterface $request): ResponseInterface
$this->contextFactory->create(),
$data['variables'] ?? []
);
$statusCode = $this->getHttpResponseCode($result);
} catch (GraphQlAuthenticationException $error) {
$result['errors'][] = $this->graphQlError->create($error);
$statusCode = 401;
} catch (GraphQlAuthorizationException $error) {
$result['errors'][] = $this->graphQlError->create($error);
$statusCode = 403;
} catch (\Exception $error) {
$result['errors'] = isset($result['errors']) ? $result['errors'] : [];
$result['errors'][] = $this->graphQlError->create($error);
$statusCode = ExceptionFormatter::HTTP_GRAPH_QL_SCHEMA_ERROR_STATUS;
}
Expand All @@ -231,32 +224,6 @@ public function dispatch(RequestInterface $request): ResponseInterface
return $this->httpResponse;
}

/**
* Retrieve http response code based on the error categories
*
* @param array $result
* @return int
*/
private function getHttpResponseCode(array $result): int
{
if (empty($result['errors'])) {
return 200;
}
foreach ($result['errors'] as $error) {
if (!isset($error['extensions']['category'])) {
continue;
}
switch ($error['extensions']['category']) {
case GraphQlAuthenticationException::EXCEPTION_CATEGORY:
return 401;
case GraphQlAuthorizationException::EXCEPTION_CATEGORY:
return 403;
}
}

return 200;
}

/**
* Get data from request body or query string
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQl\ResolverCacheAbstract;
use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException;

/**
* Test for customer resolver cache
Expand Down Expand Up @@ -541,7 +542,7 @@ public function testGuestQueryingCustomerDoesNotGenerateResolverCacheEntry()
$query
);
$this->fail('Expected exception not thrown');
} catch (\Exception $e) {
} catch (ResponseContainsErrorsException $e) {
// expected exception
}

Expand Down
Loading

0 comments on commit a182f92

Please sign in to comment.