Skip to content

Commit 5acf016

Browse files
committed
BREAKING upgrade to webonyx/graphql-php 15
`TypesInterface::get()` return type is stricter. And all breaking changes from webonyx/graphql-php also applies.
1 parent 4e14f20 commit 5acf016

30 files changed

+587
-596
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"php": "^8.2",
4040
"doctrine/orm": "^2.15",
4141
"psr/container": "^1.1 || ^2.0",
42-
"webonyx/graphql-php": "^14.11"
42+
"webonyx/graphql-php": "^15.7"
4343
},
4444
"require-dev": {
4545
"friendsofphp/php-cs-fixer": "@stable",

composer.lock

Lines changed: 28 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ parameters:
99
checkMissingIterableValueType: false
1010
checkGenericClassInNonGenericObjectType: false
1111
ignoreErrors:
12-
- '~^Parameter #1 \$wrappedType of static method GraphQL\\Type\\Definition\\Type::~'
1312
- '~^Parameter #2 \$type of static method GraphQL\\Doctrine\\Utils::getOperatorTypeName~'
1413
- '~^Parameter #1 \$method of method GraphQL\\Doctrine\\Factory\\AbstractFieldsConfigurationFactory\:\:getMethodFullName\(\) expects ReflectionMethod, ReflectionFunctionAbstract given\.$~'
1514
- '~^Parameter #3 \$subject of function preg_replace expects array\|string, string\|null given\.$~'
1615
- '~^Parameter #2 \$type of method GraphQL\\Doctrine\\Factory\\AbstractFactory::adjustNamespace\(\) expects string, string\|null given\.$~'
1716
- '~^Parameter #1 \$driver of method Doctrine\\Persistence\\Mapping\\Driver\\MappingDriverChain\:\:setDefaultDriver\(\) expects Doctrine\\Persistence\\Mapping\\Driver\\MappingDriver, Doctrine\\Persistence\\Mapping\\Driver\\MappingDriver\|null given\.$~'
17+
- '~^Parameter \#1 \$type of static method GraphQL\\Type\\Definition\\Type\:\:nonNull\(\) expects~'
18+
- '~^Parameter \#1 \$config of class GraphQL\\Type\\Definition\\InputObjectType constructor expects~'
19+
- '~^Parameter \#1 \$config of method GraphQL\\Type\\Definition\\InputObjectType\:\:__construct~'

src/Factory/AbstractFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use GraphQL\Doctrine\Attribute\Exclude;
99
use GraphQL\Doctrine\Attribute\Reader\Reader;
1010
use GraphQL\Doctrine\Types;
11+
use GraphQL\Type\Definition\NamedType;
1112
use GraphQL\Type\Definition\Type;
1213
use ReflectionClass;
1314
use ReflectionProperty;
@@ -48,7 +49,7 @@ final protected function isPropertyExcluded(ReflectionProperty $property): bool
4849
* - `MyType[]|null`
4950
* - `Collection<MyType>`
5051
*/
51-
final protected function getTypeFromPhpDeclaration(ReflectionClass $class, null|string|Type $typeDeclaration, bool $isEntityId = false): ?Type
52+
final protected function getTypeFromPhpDeclaration(ReflectionClass $class, null|string|Type $typeDeclaration, bool $isEntityId = false): null|Type
5253
{
5354
if ($typeDeclaration === null || $typeDeclaration instanceof Type) {
5455
return $typeDeclaration;
@@ -70,6 +71,7 @@ final protected function getTypeFromPhpDeclaration(ReflectionClass $class, null|
7071
$type = Type::nonNull($type);
7172
}
7273

74+
// @phpstan-ignore-next-line
7375
return $type;
7476
}
7577

@@ -97,7 +99,7 @@ private function adjustNamespace(ReflectionClass $class, string $type): string
9799
/**
98100
* Returns a type from our registry.
99101
*/
100-
final protected function getTypeFromRegistry(string $type, bool $isEntityId): Type
102+
final protected function getTypeFromRegistry(string $type, bool $isEntityId): NamedType
101103
{
102104
if ($this->types->isEntity($type) && $isEntityId) {
103105
// @phpstan-ignore-next-line

src/Factory/AbstractFieldsConfigurationFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ final protected function reflectionTypeToType(ReflectionNamedType $reflectionTyp
134134
$type = Type::nonNull($type);
135135
}
136136

137+
// @phpstan-ignore-next-line
137138
return $type;
138139
}
139140

@@ -227,7 +228,7 @@ final protected function throwIfNotInputType(ReflectionParameter $param, Abstrac
227228
}
228229

229230
if ($type instanceof WrappingType) {
230-
$type = $type->getWrappedType(true);
231+
$type = $type->getInnermostType();
231232
}
232233

233234
if (!($type instanceof InputType)) {

src/Factory/FilteredQueryBuilderFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ private function applyGroups(ClassMetadata $metadata, InputObjectType $type, arr
6767
$groups = $type->getField('groups')->getType();
6868

6969
/** @var InputObjectType $unwrapped */
70-
$unwrapped = $groups->getWrappedType(true);
70+
$unwrapped = $groups->getInnermostType();
7171

7272
/** @var ListOfType $conditions */
7373
$conditions = $unwrapped->getField('conditions')->getType();
7474

7575
/** @var InputObjectType $typeFields */
76-
$typeFields = $conditions->getWrappedType(true);
76+
$typeFields = $conditions->getInnermostType();
7777
foreach ($filter['groups'] ?? [] as $group) {
7878
$this->applyJoinsAndFilters($metadata, $alias, $typeFields, $group['joins'] ?? [], $group['conditions'] ?? []);
7979
$this->applyCollectedDqlConditions($group);

src/Factory/Type/AbstractTypeFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use GraphQL\Doctrine\Exception;
88
use GraphQL\Doctrine\Factory\AbstractFactory;
9+
use GraphQL\Type\Definition\NamedType;
910
use GraphQL\Type\Definition\Type;
1011
use ReflectionClass;
1112

@@ -20,7 +21,7 @@ abstract class AbstractTypeFactory extends AbstractFactory
2021
* @param class-string $className class name of Doctrine entity
2122
* @param string $typeName GraphQL type name
2223
*/
23-
abstract public function create(string $className, string $typeName): Type;
24+
abstract public function create(string $className, string $typeName): NamedType;
2425

2526
/**
2627
* Get the description of a class from the doc block.

src/Factory/Type/EntityIDTypeFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ final class EntityIDTypeFactory extends AbstractTypeFactory
1818
*
1919
* @param class-string $className class name of Doctrine entity
2020
* @param string $typeName GraphQL type name
21-
*
22-
* @return EntityIDType
2321
*/
24-
public function create(string $className, string $typeName): Type
22+
public function create(string $className, string $typeName): EntityIDType
2523
{
2624
$identifiers = $this->entityManager->getClassMetadata($className)->getIdentifier();
2725
if (count($identifiers) > 1) {

src/Factory/Type/FilterGroupConditionTypeFactory.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ final class FilterGroupConditionTypeFactory extends AbstractTypeFactory
4444
*
4545
* @param class-string $className class name of Doctrine entity
4646
* @param string $typeName GraphQL type name
47-
*
48-
* @return InputObjectType
4947
*/
50-
public function create(string $className, string $typeName): Type
48+
public function create(string $className, string $typeName): InputObjectType
5149
{
5250
$type = new InputObjectType([
5351
'name' => $typeName,
@@ -247,8 +245,14 @@ private function getOperators(string $fieldName, LeafType $leafType, bool $isAss
247245
*/
248246
private function getFieldType(string $typeName, string $fieldName, array $operators): InputObjectType
249247
{
248+
$fieldTypeName = $typeName . ucfirst($fieldName);
249+
if ($this->types->has($fieldTypeName)) {
250+
// @phpstan-ignore-next-line
251+
return $this->types->get($fieldTypeName);
252+
}
253+
250254
$fieldType = new InputObjectType([
251-
'name' => $typeName . ucfirst($fieldName),
255+
'name' => $fieldTypeName,
252256
'description' => 'Type to specify a condition on a specific field',
253257
'fields' => $this->getOperatorConfiguration($operators),
254258
]);

src/Factory/Type/FilterGroupJoinTypeFactory.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ final class FilterGroupJoinTypeFactory extends AbstractTypeFactory
1919
*
2020
* @param class-string $className class name of Doctrine entity
2121
* @param string $typeName GraphQL type name
22-
*
23-
* @return InputObjectType
2422
*/
25-
public function create(string $className, string $typeName): Type
23+
public function create(string $className, string $typeName): InputObjectType
2624
{
2725
$type = new InputObjectType([
2826
'name' => $typeName,

0 commit comments

Comments
 (0)