From c87c6a4d297cc643b568213e59e67f078f16efd4 Mon Sep 17 00:00:00 2001 From: Simon Gadient Date: Mon, 17 Oct 2022 12:36:52 +0200 Subject: [PATCH] Write error to logger --- Classes/Transform/FlowErrorTransform.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Classes/Transform/FlowErrorTransform.php b/Classes/Transform/FlowErrorTransform.php index b1eba10..6b79d25 100644 --- a/Classes/Transform/FlowErrorTransform.php +++ b/Classes/Transform/FlowErrorTransform.php @@ -9,6 +9,7 @@ use GraphQLTools\Transforms\Transform; use Neos\Flow\Annotations as Flow; use Neos\Flow\Log\ThrowableStorageInterface; +use Psr\Log\LoggerInterface; class FlowErrorTransform implements Transform { @@ -19,6 +20,13 @@ class FlowErrorTransform implements Transform */ protected $throwableStorage; + /** + * @Flow\Inject + * + * @var LoggerInterface + */ + protected $logger; + /** * @Flow\InjectConfiguration("includeExceptionMessageInOutput") * @@ -32,6 +40,7 @@ public function transformResult(ExecutionResult $result): ExecutionResult $previousError = $error->getPrevious(); if (! $previousError instanceof Error) { $message = $this->throwableStorage->logThrowable($previousError); + $this->logger->error('GraphQL response with error. The error has bubbled up to the next nullable field: ' . $message); if (! $this->includeExceptionMessageInOutput) { $message = preg_replace('/.* - See also: (.+)\.txt$/', 'Internal error ($1)', $message);