Skip to content

Commit 65b397c

Browse files
committed
UploadMiddleware is now optional
The ecodev/graphql-upload package is now optional and this commit makes the bundle aware that the UploadMiddleware class might not exist.
1 parent 7f7b8fe commit 65b397c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Controller/GraphqliteController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use GraphQL\Server\ServerConfig;
1818
use GraphQL\Server\StandardServer;
1919
use GraphQL\Upload\UploadMiddleware;
20+
use function class_exists;
2021
use function json_decode;
2122
use Psr\Http\Message\ServerRequestInterface;
2223
use RuntimeException;
@@ -83,8 +84,10 @@ public function handleRequest(Request $request): Response
8384
}
8485

8586
// Let's parse the request and adapt it for file uploads.
86-
$uploadMiddleware = new UploadMiddleware();
87-
$psr7Request = $uploadMiddleware->processRequest($psr7Request);
87+
if (class_exists(UploadMiddleware::class)) {
88+
$uploadMiddleware = new UploadMiddleware();
89+
$psr7Request = $uploadMiddleware->processRequest($psr7Request);
90+
}
8891

8992
return $this->handlePsr7Request($psr7Request, $request);
9093
}

0 commit comments

Comments
 (0)