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 2424use Magento \Framework \GraphQl \Query \Resolver \ContextInterface ;
2525use Magento \Framework \GraphQl \Schema \SchemaGeneratorInterface ;
2626use Magento \Framework \Serialize \SerializerInterface ;
27+ use Magento \Framework \Webapi \Exception ;
2728use Magento \Framework \Webapi \Response ;
2829use Magento \GraphQl \Helper \Query \Logger \LogData ;
30+ use Magento \GraphQl \Model \Backpressure \GraphQlTooManyRequestsException ;
2931use Magento \GraphQl \Model \Query \ContextFactoryInterface ;
3032use Magento \GraphQl \Model \Query \Logger \LoggerPool ;
3133
@@ -194,6 +196,19 @@ public function dispatch(RequestInterface $request): ResponseInterface
194196 $ this ->contextFactory ->create (),
195197 $ data ['variables ' ] ?? []
196198 );
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+ }
197212 } catch (\Exception $ error ) {
198213 $ result ['errors ' ] = isset ($ result ['errors ' ]) ? $ result ['errors ' ] : [];
199214 $ result ['errors ' ][] = $ this ->graphQlError ->create ($ error );
You can’t perform that action at this time.
0 commit comments