File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
app/code/Magento/GraphQl/Controller
dev/tests/integration/testsuite/Magento/GraphQl/Controller Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \GraphQl \Controller ;
9
9
10
+ use GraphQL \Error \FormattedError ;
11
+ use GraphQL \Error \SyntaxError ;
10
12
use Magento \Framework \App \Area ;
11
13
use Magento \Framework \App \AreaList ;
12
14
use Magento \Framework \App \FrontControllerInterface ;
@@ -206,6 +208,11 @@ public function dispatch(RequestInterface $request): ResponseInterface
206
208
);
207
209
$ statusCode = 200 ;
208
210
}
211
+ } catch (SyntaxError $ error ) {
212
+ $ result = [
213
+ 'errors ' => [FormattedError::createFromException ($ error )],
214
+ ];
215
+ $ statusCode = 400 ;
209
216
} catch (\Exception $ error ) {
210
217
$ result = [
211
218
'errors ' => [$ this ->graphQlError ->create ($ error )],
Original file line number Diff line number Diff line change @@ -272,4 +272,14 @@ public function testDispatchWithOptions(): void
272
272
self ::assertEquals (204 , $ response ->getStatusCode ());
273
273
self ::assertEmpty ($ response ->getContent ());
274
274
}
275
+
276
+ public function testDispatchWithoutQuery (): void
277
+ {
278
+ $ this ->request ->setPathInfo ('/graphql ' );
279
+ $ this ->request ->setMethod ('GET ' );
280
+ $ response = $ this ->graphql ->dispatch ($ this ->request );
281
+ self ::assertEquals (400 , $ response ->getStatusCode ());
282
+ $ output = $ this ->jsonSerializer ->unserialize ($ response ->getContent ());
283
+ self ::assertNotEmpty ($ output ['errors ' ]);
284
+ }
275
285
}
You can’t perform that action at this time.
0 commit comments