Skip to content

Commit

Permalink
BREAKING upgrade to webonyx/graphql-php 15 #9900
Browse files Browse the repository at this point in the history
  • Loading branch information
PowerKiKi committed Nov 2, 2023
1 parent c5c7e6b commit 8b5bbab
Show file tree
Hide file tree
Showing 32 changed files with 95 additions and 134 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"cakephp/chronos": "^2.4",
"doctrine/dbal": "^3.6",
"doctrine/migrations": "^3.6",
"ecodev/graphql-doctrine": "^8.1",
"ecodev/graphql-doctrine": "^9.0",
"imagine/imagine": "^1.3",
"laminas/laminas-diactoros": "^3.1",
"laminas/laminas-log": "^2.16",
Expand Down
75 changes: 42 additions & 33 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ parameters:
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
ignoreErrors:
- '~^Method Ecodev\\Felix\\Api\\Server\:\:execute\(\) should return array\<GraphQL\\Executor\\ExecutionResult\>\|GraphQL\\Executor\\ExecutionResult but returns array\<GraphQL\\Executor\\ExecutionResult\>\|GraphQL\\Executor\\ExecutionResult\|GraphQL\\Executor\\Promise\\Promise\.$~'
- '~^Method Ecodev\\Felix\\Api\\Server\:\:execute\(\) should return array\<GraphQL\\Executor\\ExecutionResult\>\|GraphQL\\Executor\\ExecutionResult but returns array\<int, GraphQL\\Executor\\ExecutionResult\>\|GraphQL\\Executor\\ExecutionResult\|GraphQL\\Executor\\Promise\\Promise\.$~'
- '~^Cannot call method getInstance\(\) on Laminas\\Permissions\\Acl\\Resource\\ResourceInterface\|null\.$~'
- '~^Parameter \#1 \$object of static method Ecodev\\Felix\\Utility\:\:getShortClassName\(\) expects class\-string\|object, string given\.$~'
- '~^Parameter #1 \$wrappedType of static method GraphQL\\Type\\Definition\\Type\:\:nonNull\(\) expects \(callable\(\)\: mixed\)\|GraphQL\\Type\\Definition\\NullableType, GraphQL\\Type\\Definition\\LeafType given\.$~'
- '~^Property EcodevTests\\Felix\\Blog\\Model\\.*\:\:\$.* is never read, only written\.$~'
- '~^Property EcodevTests\\Felix\\Blog\\Model\\.*\:\:\$.* is unused\.$~'
- '~^Cannot cast mixed to int\.$~'
- '~^Cannot cast mixed to string\.$~'
- '~^Parameter \#1 \$wrappedType of static method GraphQL\\Type\\Definition\\Type\:\:nonNull\(\) expects \(callable\(\)\: mixed\)\|GraphQL\\Type\\Definition\\NullableType, GraphQL\\Type\\Definition\\Type given\.$~'
- '~^Parameter \#1 \$type of static method GraphQL\\Type\\Definition\\Type\:\:nonNull\(\) expects~'

includes:
- phpstan-baseline.neon
Expand Down
5 changes: 0 additions & 5 deletions src/Api/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
*/
class Exception extends \Exception implements ClientAware
{
public function getCategory(): string
{
return 'Permissions';
}

public function isClientSafe(): bool
{
return true;
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/CHFType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

final class CHFType extends AbstractMoneyType
{
/**
* @var string
*/
public $description = 'A CHF money amount.';
public ?string $description = 'A CHF money amount.';

/**
* @param numeric-string $value
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/ChronosType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@

final class ChronosType extends ScalarType
{
/**
* @var string
*/
public $description = 'A date with time and timezone.';
public ?string $description = 'A date with time and timezone.';

/**
* Serializes an internal value to include in a response.
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/ColorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

final class ColorType extends AbstractStringBasedType
{
/**
* @var string
*/
public $description = 'A color expressed in hexadecimal CSS notation (eg: `#AA00FF`) or an empty string `""`.';
public ?string $description = 'A color expressed in hexadecimal CSS notation (eg: `#AA00FF`) or an empty string `""`.';

/**
* Validate a color in hexadecimal CSS notation.
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@

final class DateType extends ScalarType
{
/**
* @var string
*/
public $description = 'A date without time, nor timezone.';
public ?string $description = 'A date without time, nor timezone.';

/**
* Serializes an internal value to include in a response.
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/EURType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@

final class EURType extends AbstractMoneyType
{
/**
* @var string
*/
public $description = 'An EUR money amount.';
public ?string $description = 'An EUR money amount.';

/**
* @param numeric-string $value
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/LoginType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class LoginType extends AbstractStringBasedType
{
/**
* @var string
*/
public $description = 'A user login is a non-empty string containing only letters, digits, `.`, `_` and `-`.';
public ?string $description = 'A user login is a non-empty string containing only letters, digits, `.`, `_` and `-`.';

/**
* Validate a login.
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/OtpType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

class OtpType extends AbstractStringBasedType
{
/**
* @var string
*/
public $description = 'One time passcode composed of only digits';
public ?string $description = 'One time passcode composed of only digits';

/**
* Validate an OTP.
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/PasswordType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

final class PasswordType extends AbstractStringBasedType
{
/**
* @var string
*/
public $description = 'A password is a string of at least 12 characters';
public ?string $description = 'A password is a string of at least 12 characters';

/**
* Validate a password.
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Scalar/SiteIDType.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// Mock a SiteID GraphQL type without the need of a Site model
class SiteIDType extends IDType
{
public $name = 'SiteID';
public string $name = 'SiteID';

public $description = 'The ID of a site where a door is located';
public ?string $description = 'The ID of a site where a door is located';
}
5 changes: 1 addition & 4 deletions src/Api/Scalar/TokenType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

final class TokenType extends AbstractStringBasedType
{
/**
* @var string
*/
public $description = 'A user token is a lowercase hexadecimal string of 32 characters or 6 digits.';
public ?string $description = 'A user token is a lowercase hexadecimal string of 32 characters or 6 digits.';

/**
* Validate a token.
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Scalar/UrlType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

final class UrlType extends AbstractStringBasedType
{
/**
* @var string
*/
public $description = 'An absolute web URL that must start with `http` or `https` or be an empty string.';
public ?string $description = 'An absolute web URL that must start with `http` or `https` or be an empty string.';

/**
* Validate an URL.
Expand Down
10 changes: 9 additions & 1 deletion src/Api/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Ecodev\Felix\Api;

use Doctrine\DBAL\Exception\DriverException;
use GraphQL\Error\ClientAware;
use GraphQL\Error\DebugFlag;
use GraphQL\Executor\ExecutionResult;
use GraphQL\GraphQL;
Expand Down Expand Up @@ -99,6 +100,13 @@ private function handleError(Throwable $exception, callable $formatter): array
}
}

return $formatter($exception);
$result = $formatter($exception);

if (!$exception instanceof ClientAware || !$exception->isClientSafe()) {
$result['extensions'] ??= [];
$result['extensions']['category'] = 'internal';
}

return $result;
}
}
Loading

0 comments on commit 8b5bbab

Please sign in to comment.