Skip to content

Commit 0f2f9b5

Browse files
authoredAug 12, 2019
ENGCOM-5602: Query.country doesn't work #801
2 parents 383ee73 + f1cf63b commit 0f2f9b5

File tree

2 files changed

+26
-0
lines changed
  • app/code/Magento/DirectoryGraphQl/Model/Resolver
  • dev/tests/api-functional/testsuite/Magento/GraphQl/Directory

2 files changed

+26
-0
lines changed
 

‎app/code/Magento/DirectoryGraphQl/Model/Resolver/Country.php

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Magento\Framework\Reflection\DataObjectProcessor;
1616
use Magento\Directory\Api\CountryInformationAcquirerInterface;
1717
use Magento\Directory\Api\Data\CountryInformationInterface;
18+
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
1819

1920
/**
2021
* Country field resolver, used for GraphQL request processing.
@@ -53,6 +54,10 @@ public function resolve(
5354
array $value = null,
5455
array $args = null
5556
) {
57+
if (empty($args['id'])) {
58+
throw new GraphQlInputException(__('Country "id" value should be specified'));
59+
}
60+
5661
try {
5762
$country = $this->countryInformationAcquirer->getCountryInfo($args['id']);
5863
} catch (NoSuchEntityException $exception) {

‎dev/tests/api-functional/testsuite/Magento/GraphQl/Directory/CountryTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,27 @@ public function testGetCountryNotFoundException()
6767
}
6868
}
6969
}
70+
QUERY;
71+
72+
$this->graphQlQuery($query);
73+
}
74+
75+
/**
76+
* @expectedException \Exception
77+
* @expectedExceptionMessage Country "id" value should be specified
78+
*/
79+
public function testMissedInputParameterException()
80+
{
81+
$query = <<<QUERY
82+
{
83+
country {
84+
available_regions {
85+
code
86+
id
87+
name
88+
}
89+
}
90+
}
7091
QUERY;
7192

7293
$this->graphQlQuery($query);

0 commit comments

Comments
 (0)