Skip to content

Commit 9b11054

Browse files
committed
Merge branch 'MAGETWO-81530-support-all-product-types' of github.com:magento-honey-badgers/magento2ce into MAGETWO-81530-support-all-product-types
2 parents b9d1257 + ebbc94e commit 9b11054

File tree

12 files changed

+42
-61
lines changed

12 files changed

+42
-61
lines changed

app/code/Magento/BundleGraphQl/Model/Resolver/Products/Query/BundleProductPostProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function process(array $resultData)
9494
$childrenSkus[] = $link['sku'];
9595
$formattedLink = [
9696
'product' => new GraphQlNoSuchEntityException(
97-
__('Bundled product item not found')
97+
__('Bundled product not found')
9898
),
9999
'price' => $link->getPrice(),
100100
'position' => $link->getPosition(),

app/code/Magento/CatalogGraphQl/Model/ProductInterfaceTypeResolverComposite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function resolveType(array $data)
3838
foreach ($this->productTypeNameResolvers as $productTypeNameResolver) {
3939
if (!isset($data['type_id'])) {
4040
throw new GraphQlInputException(
41-
__('%1 key doesn\'t exist in product data', ['type_id'])
41+
__('Missing key %1 in product data', ['type_id'])
4242
);
4343
}
4444
$resolvedType = $productTypeNameResolver->resolveType($data);

app/code/Magento/CatalogGraphQl/Model/ProductLinkTypeResolverComposite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function resolveType(array $data)
3838
foreach ($this->productLinksTypeNameResolvers as $productLinksTypeNameResolvers) {
3939
if (!isset($data['link_type'])) {
4040
throw new GraphQlInputException(
41-
__('%1 key doesn\'t exist in product data', ['link_type'])
41+
__('Missing key %1 in product data', ['link_type'])
4242
);
4343
}
4444
$resolvedType = $productLinksTypeNameResolvers->resolveType($data);

app/code/Magento/CatalogGraphQl/Model/Resolver/Products.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function resolve(array $args, ResolverContextInterface $context)
5757

5858
if (!isset($args['search']) && !isset($args['filter'])) {
5959
throw new GraphQlInputException(
60-
__("One of 'search' or 'filter' input arguments needs to be specified in products request.")
60+
__("'search' or 'filter' input argument is required.")
6161
);
6262
} elseif (isset($args['search'])) {
6363
$searchResult = $this->searchQuery->getResult($searchCriteria);
@@ -76,8 +76,7 @@ public function resolve(array $args, ResolverContextInterface $context)
7676
if ($searchCriteria->getCurrentPage() > $maxPages && $searchResult->getTotalCount() > 0) {
7777
$currentPage = new GraphQlInputException(
7878
__(
79-
'The value specified in the currentPage attribute is greater than the number'
80-
. ' of pages available (%1).',
79+
'currentPage value %1 specified is greater than the number of pages available.',
8180
[$maxPages]
8281
)
8382
);

app/code/Magento/CustomerGraphQl/Model/Resolver/Customer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\CustomerGraphQl\Model\Resolver;
88

99
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
1011
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
1112
use Magento\GraphQl\Model\ResolverInterface;
1213
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
@@ -37,7 +38,7 @@ public function __construct(
3738
public function resolve(array $args, ResolverContextInterface $context)
3839
{
3940
if ((!$context->getUserId()) || $context->getUserType() == 4) {
40-
throw new GraphQlInputException(
41+
throw new GraphQlAuthorizationException(
4142
__(
4243
'Current customer does not have access to the resource "%1"',
4344
[\Magento\Customer\Model\Customer::ENTITY]

app/code/Magento/EavGraphQl/Model/Resolver/CustomAttributeMetadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private function createInputException(array $attribute)
9393

9494
return new GraphQlInputException(
9595
__(
96-
'Attribute input does not contain %1 for the input %2.',
96+
'Missing %1 for the input %2.',
9797
[$messagePart, $identifier]
9898
)
9999
);

app/code/Magento/EavGraphQl/Model/Resolver/Query/Type.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ public function __construct(
5858
*/
5959
public function getType(string $attributeCode, string $entityType)
6060
{
61-
try {
62-
$type = $this->typeLocator->getType($attributeCode, $entityType);
63-
} catch (LocalizedException $e) {
64-
throw new GraphQlInputException(__($e->getMessage()));
65-
}
61+
$type = $this->typeLocator->getType($attributeCode, $entityType);
6662

6763
$isComplexType = strpos($type, '\\') !== false;
6864
if ($type === TypeProcessor::NORMALIZED_ANY_TYPE) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ public function postQuery(string $query, array $variables = [], string $operatio
7373
foreach ($responseBodyArray['errors'] as $error) {
7474
if (isset($error['message'])) {
7575
$errorMessage .= $error['message'] . PHP_EOL;
76+
if (isset($error['debugMessage'])) {
77+
$errorMessage .= $error['debugMessage'] . PHP_EOL;
78+
}
7679
}
7780
if (isset($error['trace'])) {
7881
$traceString = $error['trace'];

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ExceptionFormatterDefaultModeTest.php

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,6 @@
99

1010
class ExceptionFormatterDefaultModeTest extends GraphQlAbstract
1111
{
12-
public function testInvalidEntityTypeExceptionInDefaultMode()
13-
{
14-
if (!$this->cleanCache()) {
15-
$this->fail('Cache could not be cleaned properly.');
16-
}
17-
$query
18-
= <<<QUERY
19-
{
20-
customAttributeMetadata(attributes:[
21-
{
22-
attribute_code:"sku"
23-
entity_type:"invalid"
24-
}
25-
])
26-
{
27-
items{
28-
attribute_code
29-
attribute_type
30-
entity_type
31-
}
32-
}
33-
}
34-
QUERY;
35-
$this->expectException(\Exception::class);
36-
37-
$this->expectExceptionMessage('GraphQL response contains errors: Attribute code' . ' ' .
38-
'sku of entity type invalid not configured to have a type.');
39-
40-
$this->graphQlQuery($query);
41-
}
42-
4312
public function testDuplicateEntityTypeException()
4413
{
4514
$query
@@ -86,8 +55,8 @@ public function testEmptyAttributeInputException()
8655
}
8756
QUERY;
8857
$this->expectException(\Exception::class);
89-
$this->expectExceptionMessage('GraphQL response contains errors: Attribute' . ' ' .
90-
'input does not contain attribute_code/entity_type for the input Empty AttributeInput.');
58+
$this->expectExceptionMessage('GraphQL response contains errors: Missing attribute_code/entity_type for the ' .
59+
'input Empty AttributeInput.');
9160

9261
$this->graphQlQuery($query);
9362
}
@@ -111,8 +80,8 @@ public function testAttributeWithNoEntityTypeInputException()
11180
}
11281
QUERY;
11382
$this->expectException(\Exception::class);
114-
$this->expectExceptionMessage('GraphQL response contains errors: Attribute input' . ' ' .
115-
'does not contain entity_type for the input attribute_code: sku.');
83+
$this->expectExceptionMessage('GraphQL response contains errors: Missing entity_type for the input' .
84+
' attribute_code: sku.');
11685

11786
$this->graphQlQuery($query);
11887
}
@@ -137,8 +106,8 @@ public function testAttributeWithNoAttributeCodeInputException()
137106
}
138107
QUERY;
139108
$this->expectException(\Exception::class);
140-
$this->expectExceptionMessage('GraphQL response contains errors: Attribute input' . ' ' .
141-
'does not contain attribute_code for the input entity_type: catalog_category.');
109+
$this->expectExceptionMessage('GraphQL response contains errors: Missing attribute_code for the input ' .
110+
'entity_type: catalog_category.');
142111

143112
$this->graphQlQuery($query);
144113
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchTest.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ public function testSearchWithFilterWithPageSizeEqualTotalCount()
221221
}
222222
QUERY;
223223
$this->expectException(\Exception::class);
224-
$this->expectExceptionMessage('GraphQL response contains errors: The value' . ' ' .
225-
'specified in the currentPage attribute is greater than the number of pages available (1).');
226-
$response = $this->graphQlQuery($query);
227-
$response = $response;
224+
$this->expectExceptionMessage('GraphQL response contains errors: currentPage value 1 specified is greater ' .
225+
'than the number of pages available.');
226+
$this->graphQlQuery($query);
228227
}
229228

230229
/**
@@ -636,8 +635,8 @@ public function testQueryPageOutOfBoundException()
636635
QUERY;
637636

638637
$this->expectException(\Exception::class);
639-
$this->expectExceptionMessage('GraphQL response contains errors: The value' . ' ' .
640-
'specified in the currentPage attribute is greater than the number of pages available (1).');
638+
$this->expectExceptionMessage('GraphQL response contains errors: currentPage value 1 specified is greater ' .
639+
'than the number of pages available.');
641640
$this->graphQlQuery($query);
642641
}
643642

@@ -669,8 +668,8 @@ public function testQueryWithNoSearchOrFilterArgumentException()
669668
QUERY;
670669

671670
$this->expectException(\Exception::class);
672-
$this->expectExceptionMessage('GraphQL response contains errors: One' .' ' .
673-
'of \'search\' or \'filter\' input arguments needs to be specified in products request.');
671+
$this->expectExceptionMessage('GraphQL response contains errors: \'search\' or \'filter\' input argument is ' .
672+
'required.');
674673
$this->graphQlQuery($query);
675674
}
676675

0 commit comments

Comments
 (0)