Skip to content

Commit 53a012d

Browse files
authored
Only parse request body for POST requests (#621)
1 parent 0c29090 commit 53a012d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Http/WebonyxGraphqlMiddleware.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use function json_last_error;
2828
use function json_last_error_msg;
2929
use function max;
30+
use function strtolower;
3031

3132
use const JSON_ERROR_NONE;
3233

@@ -60,7 +61,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
6061
}
6162

6263
// Let's json deserialize if this is not already done.
63-
if (empty($request->getParsedBody())) {
64+
if (strtolower($request->getMethod()) === 'post' && empty($request->getParsedBody())) {
6465
$content = $request->getBody()->getContents();
6566
$data = json_decode($content, true);
6667

@@ -75,8 +76,8 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
7576
if ($context instanceof ResetableContextInterface) {
7677
$context->reset();
7778
}
79+
7880
$result = $this->standardServer->executePsrRequest($request);
79-
//return $this->standardServer->processPsrRequest($request, $this->responseFactory->createResponse(), $this->streamFactory->createStream());
8081

8182
return $this->getJsonResponse($this->processResult($result), $this->decideHttpCode($result));
8283
}

0 commit comments

Comments
 (0)