File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
app/code/Magento/GraphQl/Helper/Query/Logger
dev/tests/integration/testsuite/Magento/GraphQl/Helper/Query/Logger Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -40,10 +40,13 @@ public function getLogData(
40
40
) : array {
41
41
$ logData = [];
42
42
$ logData = array_merge ($ logData , $ this ->gatherRequestInformation ($ request ));
43
- if ($ schema ) {
44
- $ logData = array_merge ($ logData , $ this ->gatherQueryInformation ($ schema ));
43
+ $ complexity = $ this ->getFieldCount ($ data ['query ' ] ?? '' );
44
+ if ($ complexity !== -1 ) {
45
+ $ logData [LoggerInterface::COMPLEXITY ] = $ complexity ;
46
+ if ($ schema ) {
47
+ $ logData = array_merge ($ logData , $ this ->gatherQueryInformation ($ schema ));
48
+ }
45
49
}
46
- $ logData [LoggerInterface::COMPLEXITY ] = $ this ->getFieldCount ($ data ['query ' ] ?? '' );
47
50
if ($ response ) {
48
51
$ logData = array_merge ($ logData , $ this ->gatherResponseInformation ($ response ));
49
52
}
@@ -129,8 +132,8 @@ private function getFieldCount(string $query): int
129
132
);
130
133
return $ totalFieldCount ;
131
134
}
132
- } catch (SyntaxError $ syntaxError ) {
133
135
} catch (\Exception $ exception ) {
136
+ return -1 ;
134
137
}
135
138
return 0 ;
136
139
}
Original file line number Diff line number Diff line change @@ -204,6 +204,32 @@ public function getQueryInformationDataProvider()
204
204
LoggerInterface::HTTP_RESPONSE_CODE => 200
205
205
]
206
206
],
207
+ [ // bad query
208
+ 'query ' => <<<QUERY
209
+ {
210
+ xyz()
211
+ {
212
+ dfsfa
213
+ sku
214
+ }
215
+ }
216
+ }
217
+ QUERY ,
218
+ 'headers ' => [
219
+ 'response ' => [
220
+ 'X-Magento-Tags ' => 'FPC '
221
+ ]
222
+ ],
223
+ 'expectedResult ' => [
224
+ LoggerInterface::HTTP_METHOD => 'POST ' ,
225
+ LoggerInterface::STORE_HEADER => '' ,
226
+ LoggerInterface::CURRENCY_HEADER => '' ,
227
+ LoggerInterface::HAS_AUTH_HEADER => 'false ' ,
228
+ LoggerInterface::IS_CACHEABLE => 'true ' ,
229
+ LoggerInterface::REQUEST_LENGTH => '' ,
230
+ LoggerInterface::HTTP_RESPONSE_CODE => 200
231
+ ]
232
+ ],
207
233
[ // mutation with all headers
208
234
'query ' => <<<QUERY
209
235
mutation {
You can’t perform that action at this time.
0 commit comments