Skip to content

Commit d023d48

Browse files
author
Eric Bohanon
committed
Merge remote-tracking branch 'remotes/origin/MAGETWO-81530-support-all-product-types' into MAGETWO-81530-support-all-product-types
2 parents 5a2f4e7 + f8b9536 commit d023d48

File tree

6 files changed

+27
-10
lines changed

6 files changed

+27
-10
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\BundleGraphQl\Model\Plugin\Model\Resolver\Products\DataProvider\Product\Formatter;
7+
namespace Magento\BundleGraphQl\Model\Resolver\Products\DataProvider\Product\Formatter;
88

99
use Magento\Catalog\Model\Product;
1010
use Magento\Bundle\Model\Product\Type as Bundle;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\FormatterComposite">
1010
<arguments>
1111
<argument name="formatterInstances" xsi:type="array">
12-
<item name="add_bundle_data" xsi:type="object">Magento\BundleGraphQl\Model\Plugin\Model\Resolver\Products\DataProvider\Product\Formatter\BundleOptions</item>
12+
<item name="add_bundle_data" xsi:type="object">Magento\BundleGraphQl\Model\Resolver\Products\DataProvider\Product\Formatter\BundleOptions</item>
1313
</argument>
1414
</arguments>
1515
</type>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\ConfigurableProductGraphQl\Model\Plugin\Model\Resolver\Products\DataProvider\Product\Formatter;
7+
namespace Magento\ConfigurableProductGraphQl\Model\Resolver\Products\DataProvider\Product\Formatter;
88

99
use Magento\Catalog\Model\Product;
1010
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<type name="Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\FormatterComposite">
1010
<arguments>
1111
<argument name="formatterInstances" xsi:type="array">
12-
<item name="add_configurable_data" xsi:type="object">Magento\ConfigurableProductGraphQl\Model\Plugin\Model\Resolver\Products\DataProvider\Product\Formatter\ConfigurableOptions</item>
12+
<item name="add_configurable_data" xsi:type="object">Magento\ConfigurableProductGraphQl\Model\Resolver\Products\DataProvider\Product\Formatter\ConfigurableOptions</item>
1313
</argument>
1414
</arguments>
1515
</type>

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

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,25 @@ public function postQuery(string $query, array $variables = [], string $operatio
6767
$responseBody = $this->curlClient->post($url, $postData, $headers);
6868
$responseBodyArray = $this->json->jsonDecode($responseBody);
6969

70+
if (!is_array($responseBodyArray)) {
71+
throw new \Exception('Unknown GraphQL response body: ' . json_encode($responseBodyArray));
72+
}
73+
74+
$this->processErrors($responseBodyArray);
75+
76+
if (!isset($responseBodyArray['data'])) {
77+
throw new \Exception('Unknown GraphQL response body: ' . json_encode($responseBodyArray));
78+
} else {
79+
return $responseBodyArray['data'];
80+
}
81+
}
82+
83+
/**
84+
* @param array $responseBodyArray
85+
* @throws \Exception
86+
*/
87+
private function processErrors($responseBodyArray)
88+
{
7089
if (isset($responseBodyArray['errors'])) {
7190
$errorMessage = '';
7291
if (is_array($responseBodyArray['errors'])) {
@@ -85,12 +104,8 @@ public function postQuery(string $query, array $variables = [], string $operatio
85104

86105
throw new \Exception('GraphQL response contains errors: ' . $errorMessage);
87106
}
88-
throw new \Exception('GraphQL responded with an unknown error: ' . $responseBody);
89-
} elseif (!isset($responseBodyArray['data'])) {
90-
throw new \Exception('Unknown GraphQL response body: ' . $responseBody);
107+
throw new \Exception('GraphQL responded with an unknown error: ' . json_encode($responseBodyArray));
91108
}
92-
93-
return $responseBodyArray['data'];
94109
}
95110

96111
/**
@@ -99,6 +114,6 @@ public function postQuery(string $query, array $variables = [], string $operatio
99114
*/
100115
public function getEndpointUrl()
101116
{
102-
return rtrim(TESTS_BASE_URL, '/') . '/graphql';
117+
return rtrim(TESTS_BASE_URL, '/') . '/graphql5';
103118
}
104119
}

lib/internal/Magento/Framework/GraphQl/Config/Data/TypeResolverInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
namespace Magento\Framework\GraphQl\Config\Data;
88

9+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
910
/**
1011
* Determines a concrete GraphQL type for data returned that implements an interface type.
1112
*/
@@ -16,6 +17,7 @@ interface TypeResolverInterface
1617
*
1718
* @param array $data
1819
* @return string|null
20+
* @throws GraphQlInputException
1921
*/
2022
public function resolveType(array $data);
2123
}

0 commit comments

Comments
 (0)