Skip to content

Commit

Permalink
fix: add support for decoration via RequestHandlerMiddlewareAdapter. s…
Browse files Browse the repository at this point in the history
  • Loading branch information
sig-critchie committed Feb 9, 2021
1 parent f356413 commit 1e8156a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use SilverStripe\Control\HTTPRequest;
use SilverStripe\GraphQL\Controller as GraphQLController;
use SilverStripe\Control\Director;
use SilverStripe\Control\Middleware\RequestHandlerMiddlewareAdapter;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Injector\InjectorNotFoundException;
use SilverStripe\Core\Path;
Expand Down Expand Up @@ -101,6 +102,12 @@ protected function findAvailableRoutes($schemas = []): array

try {
$routeController = Injector::inst()->get($routeClass);

// Add support for decoration via RequestHandlerMiddlewareAdapter
if ($routeController instanceof RequestHandlerMiddlewareAdapter) {
$routeController = $routeController->getRequestHandler();
}

if ($routeController instanceof GraphQLController) {
$schemaKey = class_exists(Schema::class)
? $routeController->getSchema()->getSchemaKey()
Expand Down

0 comments on commit 1e8156a

Please sign in to comment.