File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
app/code/Magento/GraphQl/Controller Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 24
24
use Magento \Framework \GraphQl \Query \Resolver \ContextInterface ;
25
25
use Magento \Framework \GraphQl \Schema \SchemaGeneratorInterface ;
26
26
use Magento \Framework \Serialize \SerializerInterface ;
27
+ use Magento \Framework \Webapi \Exception ;
27
28
use Magento \Framework \Webapi \Response ;
28
29
use Magento \GraphQl \Helper \Query \Logger \LogData ;
30
+ use Magento \GraphQl \Model \Backpressure \GraphQlTooManyRequestsException ;
29
31
use Magento \GraphQl \Model \Query \ContextFactoryInterface ;
30
32
use Magento \GraphQl \Model \Query \Logger \LoggerPool ;
31
33
@@ -194,6 +196,19 @@ public function dispatch(RequestInterface $request): ResponseInterface
194
196
$ this ->contextFactory ->create (),
195
197
$ data ['variables ' ] ?? []
196
198
);
199
+
200
+ if (isset ($ result ['errors ' ]) && is_array ($ result ['errors ' ])) {
201
+ foreach ($ result ['errors ' ] as $ error ) {
202
+ if (isset ($ error ['extensions ' ]) && is_array ($ error ['extensions ' ])) {
203
+ foreach ($ error ['extensions ' ] as $ key => $ value ) {
204
+ if (GraphQlTooManyRequestsException::EXCEPTION_CATEGORY === $ value
205
+ && 'category ' === $ key ) {
206
+ $ statusCode = Exception::HTTP_TOO_MANY_REQUESTS ;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ }
197
212
} catch (\Exception $ error ) {
198
213
$ result ['errors ' ] = isset ($ result ['errors ' ]) ? $ result ['errors ' ] : [];
199
214
$ result ['errors ' ][] = $ this ->graphQlError ->create ($ error );
You can’t perform that action at this time.
0 commit comments