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 77
88namespace Magento \GraphQl \Controller ;
99
10+ use GraphQL \Error \FormattedError ;
11+ use GraphQL \Error \SyntaxError ;
1012use Magento \Framework \App \Area ;
1113use Magento \Framework \App \AreaList ;
1214use Magento \Framework \App \FrontControllerInterface ;
@@ -206,6 +208,11 @@ public function dispatch(RequestInterface $request): ResponseInterface
206208 );
207209 $ statusCode = 200 ;
208210 }
211+ } catch (SyntaxError $ error ) {
212+ $ result = [
213+ 'errors ' => [FormattedError::createFromException ($ error )],
214+ ];
215+ $ statusCode = 400 ;
209216 } catch (\Exception $ error ) {
210217 $ result = [
211218 'errors ' => [$ this ->graphQlError ->create ($ error )],
Original file line number Diff line number Diff line change @@ -272,4 +272,14 @@ public function testDispatchWithOptions(): void
272272 self ::assertEquals (204 , $ response ->getStatusCode ());
273273 self ::assertEmpty ($ response ->getContent ());
274274 }
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+ }
275285}
You can’t perform that action at this time.
0 commit comments