File tree Expand file tree Collapse file tree 1 file changed +17
-15
lines changed
app/code/Magento/GraphQl/Controller/HttpRequestValidator Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -31,23 +31,25 @@ public function validate(HttpRequestInterface $request) : void
3131 /** @var Http $request */
3232 if (false === $ request ->isPost ()) {
3333 $ query = $ request ->getParam ('query ' , '' );
34- $ operationType = null ;
35- $ queryAst = \GraphQL \Language \Parser::parse (new \GraphQL \Language \Source ($ query ?: '' , 'GraphQL ' ));
36- \GraphQL \Language \Visitor::visit (
37- $ queryAst ,
38- [
39- 'leave ' => [
40- NodeKind::OPERATION_DEFINITION => function (Node $ node ) use (&$ operationType ) {
41- $ operationType = $ node ->operation ;
42- }
34+ if (!empty ($ query )) {
35+ $ operationType = null ;
36+ $ queryAst = \GraphQL \Language \Parser::parse (new \GraphQL \Language \Source ($ query ?: '' , 'GraphQL ' ));
37+ \GraphQL \Language \Visitor::visit (
38+ $ queryAst ,
39+ [
40+ 'leave ' => [
41+ NodeKind::OPERATION_DEFINITION => function (Node $ node ) use (&$ operationType ) {
42+ $ operationType = $ node ->operation ;
43+ }
44+ ]
4345 ]
44- ]
45- );
46-
47- if (strtolower ($ operationType ) === 'mutation ' ) {
48- throw new GraphQlInputException (
49- new \Magento \Framework \Phrase ('Mutation requests allowed only for POST requests ' )
5046 );
47+
48+ if (strtolower ($ operationType ) === 'mutation ' ) {
49+ throw new GraphQlInputException (
50+ new \Magento \Framework \Phrase ('Mutation requests allowed only for POST requests ' )
51+ );
52+ }
5153 }
5254 }
5355 }
You can’t perform that action at this time.
0 commit comments