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
31
31
/** @var Http $request */
32
32
if (false === $ request ->isPost ()) {
33
33
$ 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
+ ]
43
45
]
44
- ]
45
- );
46
-
47
- if (strtolower ($ operationType ) === 'mutation ' ) {
48
- throw new GraphQlInputException (
49
- new \Magento \Framework \Phrase ('Mutation requests allowed only for POST requests ' )
50
46
);
47
+
48
+ if (strtolower ($ operationType ) === 'mutation ' ) {
49
+ throw new GraphQlInputException (
50
+ new \Magento \Framework \Phrase ('Mutation requests allowed only for POST requests ' )
51
+ );
52
+ }
51
53
}
52
54
}
53
55
}
You can’t perform that action at this time.
0 commit comments