Skip to content

Commit 646f0b6

Browse files
authored
Merge pull request #57 from simPod/bump-graphql-php
Upgrade to graphql-php v14
2 parents 3ccaa4b + 552aa47 commit 646f0b6

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"require": {
1616
"php": "^7.3||^8.0",
1717
"thecodingmachine/safe": "^1.0.2",
18-
"webonyx/graphql-php": "^0.12||^0.13"
18+
"webonyx/graphql-php": "^14.0"
1919
},
2020
"require-dev": {
2121
"doctrine/coding-standard": "^8.1",

src/Error/FormattedError.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@
44

55
namespace SimPod\GraphQLUtils\Error;
66

7+
use GraphQL\Error\DebugFlag;
8+
use Throwable;
9+
710
class FormattedError extends \GraphQL\Error\FormattedError
811
{
912
/**
1013
* {@inheritdoc}
1114
*/
12-
public static function createFromException($e, $debug = false, $internalErrorMessage = null): array
15+
public static function createFromException(Throwable $exception, int $debug = DebugFlag::NONE, $internalErrorMessage = null): array
1316
{
14-
$arrayError = parent::createFromException($e, $debug, $internalErrorMessage);
17+
$arrayError = parent::createFromException($exception, $debug, $internalErrorMessage);
1518

16-
if ($e instanceof \GraphQL\Error\Error && $e->getPrevious() instanceof Error) {
17-
$arrayError['extensions']['type'] = $e->getPrevious()->getType();
19+
if ($exception instanceof \GraphQL\Error\Error && $exception->getPrevious() instanceof Error) {
20+
$arrayError['extensions']['type'] = $exception->getPrevious()->getType();
1821
}
1922

2023
return $arrayError;

tests/Error/FormattedErrorTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimPod\GraphQLUtils\Tests\Error;
66

77
use Exception;
8+
use GraphQL\Error\DebugFlag;
89
use GraphQL\Error\Error;
910
use PHPUnit\Framework\TestCase;
1011
use SimPod\GraphQLUtils\Error\FormattedError;
@@ -38,7 +39,7 @@ public function testDebug() : void
3839
'category' => 'internal',
3940
],
4041
],
41-
FormattedError::createFromException($exception, true)
42+
FormattedError::createFromException($exception, DebugFlag::INCLUDE_DEBUG_MESSAGE)
4243
);
4344
}
4445

@@ -55,7 +56,7 @@ public function testInternalMessageModification() : void
5556
],
5657
FormattedError::createFromException(
5758
$exception,
58-
false,
59+
DebugFlag::NONE,
5960
'Try grilling smoothie jumbled with salad cream, decorateed with green curry.'
6061
)
6162
);
@@ -67,10 +68,11 @@ public function testGraphQLCustomError() : void
6768
{
6869
public function __construct()
6970
{
70-
parent::__construct('Error Message',
71-
null,
71+
parent::__construct(
72+
'Error Message',
7273
null,
7374
null,
75+
[],
7476
null,
7577
new CustomError(''));
7678
}
@@ -84,7 +86,7 @@ public function __construct()
8486
'type' => 'CUSTOM_ERROR',
8587
],
8688
],
87-
FormattedError::createFromException($error, false)
89+
FormattedError::createFromException($error, DebugFlag::NONE)
8890
);
8991
}
9092
}

0 commit comments

Comments
 (0)