diff --git a/Classes/Controller/StandardController.php b/Classes/Controller/StandardController.php index 7d049d6..0948c18 100644 --- a/Classes/Controller/StandardController.php +++ b/Classes/Controller/StandardController.php @@ -4,6 +4,7 @@ use GraphQL\GraphQL; use Neos\Flow\Annotations as Flow; use Neos\Flow\Mvc\Controller\ActionController; +use Neos\Flow\Mvc\Exception\NoSuchArgumentException; use Wwwision\GraphQL\GraphQLContext; use Wwwision\GraphQL\SchemaService; use Wwwision\GraphQL\TypeResolver; @@ -54,6 +55,7 @@ public function indexAction($endpoint) * @param string $operationName The operation to execute (if multiple, see GraphQL::execute()) * @return void * @Flow\SkipCsrfProtection + * @throws NoSuchArgumentException */ public function queryAction($endpoint, $query, $variables = null, $operationName = null) { diff --git a/Classes/GraphQLContext.php b/Classes/GraphQLContext.php index 8f55193..d5c9012 100644 --- a/Classes/GraphQLContext.php +++ b/Classes/GraphQLContext.php @@ -1,7 +1,7 @@ httpRequest = $httpRequest; } /** - * @return HttpRequest + * @return ServerRequestInterface */ - public function getHttpRequest() + public function getHttpRequest(): ServerRequestInterface { return $this->httpRequest; } -} \ No newline at end of file +} diff --git a/Classes/Http/HttpOptionsComponent.php b/Classes/Http/HttpOptionsComponent.php index acf8a61..d16d2b7 100644 --- a/Classes/Http/HttpOptionsComponent.php +++ b/Classes/Http/HttpOptionsComponent.php @@ -28,12 +28,14 @@ public function handle(ComponentContext $componentContext) if ($httpRequest->getMethod() !== 'OPTIONS') { return; } + $endpoint = ltrim($httpRequest->getUri()->getPath(), '\/'); // no matching graphQL endpoint configured => skip - if (!isset($this->endpoints[$httpRequest->getRelativePath()])) { + if (!isset($this->endpoints[$endpoint])) { return; } $httpResponse = $componentContext->getHttpResponse(); - $httpResponse->setHeader('Allow', 'GET, POST'); + $httpResponse = $httpResponse->withHeader('Allow', 'GET, POST'); + $componentContext->replaceHttpResponse($httpResponse); $componentContext->setParameter(ComponentChain::class, 'cancel', true); } } diff --git a/Classes/Package.php b/Classes/Package.php index b29a471..39658f6 100644 --- a/Classes/Package.php +++ b/Classes/Package.php @@ -9,7 +9,7 @@ use Neos\Flow\Core\Bootstrap; use Neos\Flow\Monitor\FileMonitor; use Neos\Flow\Package\Package as BasePackage; -use Neos\Flow\Package\PackageManagerInterface; +use Neos\Flow\Package\PackageManager; use Neos\Utility\Files; use Neos\Utility\Unicode\Functions; @@ -41,7 +41,7 @@ public function boot(Bootstrap $bootstrap) $graphQlFileMonitor = FileMonitor::createFileMonitorAtBoot(self::FILE_MONITOR_IDENTIFIER, $bootstrap); $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class); $endpointsConfiguration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Wwwision.GraphQL.endpoints'); - $packageManager = $bootstrap->getEarlyInstance(PackageManagerInterface::class); + $packageManager = $bootstrap->getEarlyInstance(PackageManager::class); foreach($endpointsConfiguration as $endpointConfiguration) { if (!isset($endpointConfiguration['schema'])) { diff --git a/Classes/View/GraphQlView.php b/Classes/View/GraphQlView.php index 060b66b..33bcb95 100644 --- a/Classes/View/GraphQlView.php +++ b/Classes/View/GraphQlView.php @@ -4,11 +4,11 @@ use GraphQL\Error\Error; use GraphQL\Executor\ExecutionResult; use Neos\Flow\Annotations as Flow; -use Neos\Flow\Http\Response as HttpResponse; -use Neos\Flow\Log\SystemLoggerInterface; +use Neos\Flow\Exception as FlowException; +use Neos\Flow\Http\Helper\ResponseInformationHelper; use Neos\Flow\Log\ThrowableStorageInterface; +use Neos\Flow\Mvc\ActionResponse; use Neos\Flow\Mvc\View\AbstractView; -use Neos\Flow\Exception as FlowException; use Psr\Log\LoggerInterface; class GraphQlView extends AbstractView @@ -40,9 +40,8 @@ public function render() throw new FlowException(sprintf('The GraphQlView expects a variable "result" of type "%s", "%s" given!', ExecutionResult::class, is_object($result) ? get_class($result) : gettype($result)), 1469545198); } - /** @var HttpResponse $response */ $response = $this->controllerContext->getResponse(); - $response->setHeader('Content-Type', 'application/json'); + $response->setContentType('application/json'); return json_encode($this->formatResult($result)); } @@ -67,7 +66,7 @@ private function formatResult(ExecutionResult $executionResult) ]; $exception = $error->getPrevious(); if ($exception instanceof FlowException) { - $errorResult['message'] = HttpResponse::getStatusMessageByCode($exception->getStatusCode()); + $errorResult['message'] = ResponseInformationHelper::getStatusMessageByCode($exception->getStatusCode()); $errorResult['_exceptionCode'] = $exception->getCode(); $errorResult['_statusCode'] = $exception->getStatusCode(); $errorResult['_referenceCode'] = $exception->getReferenceCode(); @@ -84,4 +83,4 @@ private function formatResult(ExecutionResult $executionResult) } return $convertedResult; } -} \ No newline at end of file +} diff --git a/composer.json b/composer.json index fe574fa..7c9f28f 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "name": "wwwision/graphql", "license": "MIT", "require": { - "neos/flow": "^4.0 || ^5.0", + "neos/flow": "^6.0", "webonyx/graphql-php": "^0.13.0" }, "autoload": {