From db713d47c6cdbbd67b9cac3b52c64a8a95e726bc Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Wed, 21 Aug 2019 14:14:33 +0200 Subject: [PATCH 1/7] TASK: Mark the package compatible with upcoming Flow 6.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index fe574fa..59a2349 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": "^4.0 || ^5.0 || ^6.0", "webonyx/graphql-php": "^0.13.0" }, "autoload": { From a09699aca538d27d222ce4bce3fc19e704b9e2fa Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Wed, 21 Aug 2019 14:32:55 +0200 Subject: [PATCH 2/7] BUGFIX: Use PackageManager instead of removed interface --- Classes/Package.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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'])) { From 022f47ad5c601d44f562dda1c0c224b1663e4471 Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Wed, 21 Aug 2019 15:43:23 +0200 Subject: [PATCH 3/7] TASK: Exchange Classes to PSR-7 compatible ones --- Classes/View/GraphQlView.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Classes/View/GraphQlView.php b/Classes/View/GraphQlView.php index 6291115..18a4a52 100644 --- a/Classes/View/GraphQlView.php +++ b/Classes/View/GraphQlView.php @@ -1,11 +1,12 @@ controllerContext->getResponse(); - $response->setHeader('Content-Type', 'application/json'); + $response->setContentType('application/json'); return json_encode($this->formatResult($result)); } @@ -59,13 +60,13 @@ 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(); } if ($exception instanceof \Exception) { - $this->systemLogger->logException($exception); + $this->throwableStorage->logThrowable($exception); } return $errorResult; }, $executionResult->errors); @@ -75,4 +76,4 @@ private function formatResult(ExecutionResult $executionResult) } return $convertedResult; } -} \ No newline at end of file +} From 123506d2597c26e523c54e4ed9612ae7f4c57fb8 Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Mon, 26 Aug 2019 16:29:19 +0200 Subject: [PATCH 4/7] TASK: Use HttpRequestInterface instead of HttpRequest --- Classes/Controller/StandardController.php | 1 + Classes/GraphQLContext.php | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Classes/Controller/StandardController.php b/Classes/Controller/StandardController.php index 7d049d6..33a7e23 100644 --- a/Classes/Controller/StandardController.php +++ b/Classes/Controller/StandardController.php @@ -54,6 +54,7 @@ public function indexAction($endpoint) * @param string $operationName The operation to execute (if multiple, see GraphQL::execute()) * @return void * @Flow\SkipCsrfProtection + * @throws \Neos\Flow\Mvc\Exception\NoSuchArgumentException */ public function queryAction($endpoint, $query, $variables = null, $operationName = null) { diff --git a/Classes/GraphQLContext.php b/Classes/GraphQLContext.php index 8f55193..eeda648 100644 --- a/Classes/GraphQLContext.php +++ b/Classes/GraphQLContext.php @@ -1,7 +1,7 @@ httpRequest = $httpRequest; } /** - * @return HttpRequest + * @return HttpRequestInterface */ - public function getHttpRequest() + public function getHttpRequest(): HttpRequestInterface { return $this->httpRequest; } -} \ No newline at end of file +} From 6aec5ce38914a5cd7099a600e866d188c4fd6899 Mon Sep 17 00:00:00 2001 From: bwaidelich Date: Mon, 6 Jan 2020 13:47:24 +0100 Subject: [PATCH 5/7] Minor cosmetic tweaks --- Classes/Controller/StandardController.php | 3 ++- Classes/GraphQLContext.php | 12 ++++++------ Classes/View/GraphQlView.php | 1 - 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Classes/Controller/StandardController.php b/Classes/Controller/StandardController.php index 33a7e23..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,7 +55,7 @@ public function indexAction($endpoint) * @param string $operationName The operation to execute (if multiple, see GraphQL::execute()) * @return void * @Flow\SkipCsrfProtection - * @throws \Neos\Flow\Mvc\Exception\NoSuchArgumentException + * @throws NoSuchArgumentException */ public function queryAction($endpoint, $query, $variables = null, $operationName = null) { diff --git a/Classes/GraphQLContext.php b/Classes/GraphQLContext.php index eeda648..d5c9012 100644 --- a/Classes/GraphQLContext.php +++ b/Classes/GraphQLContext.php @@ -1,7 +1,7 @@ httpRequest = $httpRequest; } /** - * @return HttpRequestInterface + * @return ServerRequestInterface */ - public function getHttpRequest(): HttpRequestInterface + public function getHttpRequest(): ServerRequestInterface { return $this->httpRequest; } diff --git a/Classes/View/GraphQlView.php b/Classes/View/GraphQlView.php index 8fb2fd4..33bcb95 100644 --- a/Classes/View/GraphQlView.php +++ b/Classes/View/GraphQlView.php @@ -40,7 +40,6 @@ 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 ActionResponse $response */ $response = $this->controllerContext->getResponse(); $response->setContentType('application/json'); From 63df632af25b1d259c5d2cb600041bf8b7c24617 Mon Sep 17 00:00:00 2001 From: bwaidelich Date: Mon, 6 Jan 2020 14:01:37 +0100 Subject: [PATCH 6/7] Fix HttpOptionsComponent Thanks to @sbruggmann --- Classes/Http/HttpOptionsComponent.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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); } } From 7f6b5cd6a7a4d13ea268f2d782989affa7240e21 Mon Sep 17 00:00:00 2001 From: bwaidelich Date: Mon, 6 Jan 2020 14:02:36 +0100 Subject: [PATCH 7/7] Limit flow composer dependency to 6.0+ --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 59a2349..7c9f28f 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "name": "wwwision/graphql", "license": "MIT", "require": { - "neos/flow": "^4.0 || ^5.0 || ^6.0", + "neos/flow": "^6.0", "webonyx/graphql-php": "^0.13.0" }, "autoload": {