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 Original file line number Diff line number Diff line change 15
15
use Magento \Framework \Reflection \DataObjectProcessor ;
16
16
use Magento \Directory \Api \CountryInformationAcquirerInterface ;
17
17
use Magento \Directory \Api \Data \CountryInformationInterface ;
18
+ use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
18
19
19
20
/**
20
21
* Country field resolver, used for GraphQL request processing.
@@ -53,6 +54,10 @@ public function resolve(
53
54
array $ value = null ,
54
55
array $ args = null
55
56
) {
57
+ if (empty ($ args ['id ' ])) {
58
+ throw new GraphQlInputException (__ ('Country "id" value should be specified ' ));
59
+ }
60
+
56
61
try {
57
62
$ country = $ this ->countryInformationAcquirer ->getCountryInfo ($ args ['id ' ]);
58
63
} catch (NoSuchEntityException $ exception ) {
Original file line number Diff line number Diff line change @@ -67,6 +67,27 @@ public function testGetCountryNotFoundException()
67
67
}
68
68
}
69
69
}
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
+ }
70
91
QUERY ;
71
92
72
93
$ this ->graphQlQuery ($ query );
You can’t perform that action at this time.
0 commit comments