Skip to content

Commit be33c56

Browse files
authored
Merge pull request #947 from ruudk/remove-pin
Sync with upstream `webonyx/graphql-php` changes
2 parents 6b4a4cb + 5944e14 commit be33c56

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"symfony/framework-bundle": "^4.4 || ^5.2",
3838
"symfony/options-resolver": "^4.4 || ^5.2",
3939
"symfony/property-access": "^4.4 || ^5.2",
40-
"webonyx/graphql-php": "dev-master#d36e80962bd82b2f515617de50e0c87c8049bc3c"
40+
"webonyx/graphql-php": "dev-master"
4141
},
4242
"suggest": {
4343
"nelmio/cors-bundle": "For more flexibility when using CORS prefight",

phpstan-baseline.neon

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ parameters:
9090
count: 1
9191
path: src/Config/Processor/BuilderProcessor.php
9292

93+
-
94+
message: "#^Attribute class Overblog\\\\GraphQLBundle\\\\Definition\\\\ReturnTypeWillChange does not exist\\.$#"
95+
count: 1
96+
path: src/Definition/Argument.php
97+
98+
-
99+
message: "#^Used constant ReturnTypeWillChange not found\\.$#"
100+
count: 1
101+
path: src/Definition/Argument.php
102+
93103
-
94104
message: "#^Method Overblog\\\\GraphQLBundle\\\\Definition\\\\Builder\\\\TypeFactory\\:\\:create\\(\\) should return GraphQL\\\\Type\\\\Definition\\\\Type but returns object\\.$#"
95105
count: 1
@@ -180,6 +190,11 @@ parameters:
180190
count: 1
181191
path: src/Validator/InputValidator.php
182192

193+
-
194+
message: "#^Offset 'validation' on array\\{name\\: string, type\\: \\(callable\\(\\)\\: GraphQL\\\\Type\\\\Definition\\\\OutputType&GraphQL\\\\Type\\\\Definition\\\\Type\\)\\|\\(GraphQL\\\\Type\\\\Definition\\\\OutputType&GraphQL\\\\Type\\\\Definition\\\\Type\\), resolve\\?\\: \\(callable\\(mixed, array\\<string, mixed\\>, mixed, GraphQL\\\\Type\\\\Definition\\\\ResolveInfo\\)\\: mixed\\)\\|null, args\\?\\: array\\<string, array\\{name\\: string, defaultValue\\?\\: mixed, description\\?\\: string\\|null, astNode\\?\\: GraphQL\\\\Language\\\\AST\\\\InputValueDefinitionNode\\|null\\}\\|GraphQL\\\\Type\\\\Definition\\\\Type\\>\\|null, description\\?\\: string\\|null, deprecationReason\\?\\: string\\|null, astNode\\?\\: GraphQL\\\\Language\\\\AST\\\\FieldDefinitionNode\\|null, complexity\\?\\: \\(callable\\(int, array\\<string, mixed\\>\\)\\: int\\)\\|null\\} on left side of \\?\\? does not exist\\.$#"
195+
count: 1
196+
path: src/Validator/InputValidator.php
197+
183198
-
184199
message: "#^Unsafe call to private method Overblog\\\\GraphQLBundle\\\\Validator\\\\InputValidator\\:\\:isListOfType\\(\\) through static\\:\\:\\.$#"
185200
count: 1

src/EventListener/TypeDecoratorListener.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use GraphQL\Type\Definition\EnumType;
88
use GraphQL\Type\Definition\InterfaceType;
9+
use GraphQL\Type\Definition\NamedType;
910
use GraphQL\Type\Definition\ObjectType;
1011
use GraphQL\Type\Definition\Type;
1112
use GraphQL\Type\Definition\UnionType;
@@ -56,12 +57,12 @@ public function decorateType(Type $type, ResolverMapInterface $resolverMap): voi
5657
} elseif ($type instanceof CustomScalarType) {
5758
$this->decorateCustomScalarType($type, $resolverMap);
5859
} else {
59-
$covered = $resolverMap->covered($type->name);
60+
$covered = $resolverMap->covered($type instanceof NamedType ? $type->name : null);
6061
if (!empty($covered)) {
6162
throw new InvalidArgumentException(
6263
sprintf(
6364
'"%s".{"%s"} defined in resolverMap, but type is not managed by TypeDecorator.',
64-
$type->name,
65+
$type instanceof NamedType ? $type->name : get_class($type),
6566
implode('", "', $covered)
6667
)
6768
);
@@ -86,10 +87,7 @@ private function decorateObjectType(ObjectType $type, ResolverMapInterface $reso
8687
$this->decorateObjectTypeFields($type, $fieldsResolved, $resolverMap);
8788
}
8889

89-
/**
90-
* @param InterfaceType|UnionType $type
91-
*/
92-
private function decorateInterfaceOrUnionType($type, ResolverMapInterface $resolverMap): void
90+
private function decorateInterfaceOrUnionType(InterfaceType | UnionType $type, ResolverMapInterface $resolverMap): void
9391
{
9492
$this->configTypeMapping($type, ResolverMapInterface::RESOLVE_TYPE, $resolverMap);
9593
$covered = $resolverMap->covered($type->name);
@@ -190,7 +188,7 @@ private function decorateObjectTypeFields(ObjectType $type, array $fieldsResolve
190188
$type->config['fields'] = is_callable($fields) ? $decoratedFields : $decoratedFields();
191189
}
192190

193-
private function configTypeMapping(Type $type, string $fieldName, ResolverMapInterface $resolverMap): void
191+
private function configTypeMapping(ObjectType | InterfaceType | UnionType | CustomScalarType $type, string $fieldName, ResolverMapInterface $resolverMap): void
194192
{
195193
if ($resolverMap->isResolvable($type->name, $fieldName)) {
196194
$type->config[substr($fieldName, 2)] = $resolverMap->resolve($type->name, $fieldName);

src/Validator/InputValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function validate($groups = null, bool $throw = true): ?ConstraintViolati
7777

7878
$this->buildValidationTree(
7979
$rootNode,
80-
$this->info->fieldDefinition->config['args'],
80+
$this->info->fieldDefinition->config['args'] ?? [],
8181
$classMapping,
8282
$this->resolverArgs->args->getArrayCopy()
8383
);
@@ -212,7 +212,7 @@ protected function buildValidationTree(ValidationNode $rootObject, array $fields
212212
*/
213213
private static function isListOfType($type): bool
214214
{
215-
if ($type instanceof ListOfType || ($type instanceof NonNull && $type->getOfType() instanceof ListOfType)) {
215+
if ($type instanceof ListOfType || ($type instanceof NonNull && $type->getWrappedType() instanceof ListOfType)) {
216216
return true;
217217
}
218218

src/Validator/ValidationNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Overblog\GraphQLBundle\Validator;
66

77
use GraphQL\Type\Definition\InputObjectType;
8+
use GraphQL\Type\Definition\NamedType;
89
use GraphQL\Type\Definition\ObjectType;
910
use GraphQL\Type\Definition\ResolveInfo;
1011
use GraphQL\Type\Definition\Type;
@@ -30,9 +31,9 @@ class ValidationNode
3031
private ?string $__fieldName;
3132

3233
/**
33-
* @var ObjectType|InputObjectType|Type
34+
* @var ObjectType|InputObjectType
3435
*/
35-
private Type $__type;
36+
private NamedType $__type;
3637

3738
/**
3839
* @var ValidationNode[]
@@ -45,7 +46,7 @@ class ValidationNode
4546
private ?ResolverArgs $__resolverArgs;
4647

4748
public function __construct(
48-
Type $type,
49+
ObjectType | InputObjectType $type,
4950
string $field = null,
5051
?ValidationNode $parent = null,
5152
?ResolverArgs $resolverArgs = null

tests/EventListener/TypeDecoratorListenerTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use GraphQL\Type\Definition\InputObjectType;
1010
use GraphQL\Type\Definition\InterfaceType;
1111
use GraphQL\Type\Definition\ObjectType;
12+
use GraphQL\Type\Definition\ResolveInfo;
1213
use GraphQL\Type\Definition\Type;
1314
use GraphQL\Type\Definition\UnionType;
1415
use InvalidArgumentException;
@@ -29,10 +30,10 @@ class TypeDecoratorListenerTest extends TestCase
2930
*
3031
* @dataProvider specialTypeFieldProvider
3132
*/
32-
public function testSpecialField($fieldName, Type $typeWithSpecialField, callable $fieldValueRetriever = null, $strict = true): void
33+
public function testSpecialField($fieldName, ObjectType | UnionType | InterfaceType | CustomScalarType $typeWithSpecialField, callable $fieldValueRetriever = null, $strict = true): void
3334
{
3435
if (null === $fieldValueRetriever) {
35-
$fieldValueRetriever = fn (Type $type, $fieldName) => $type->config[$fieldName];
36+
$fieldValueRetriever = fn (ObjectType | UnionType | InterfaceType | CustomScalarType $type, $fieldName) => $type->config[$fieldName];
3637
}
3738
$expected = static function (): void {
3839
};
@@ -106,7 +107,8 @@ public function testWrappedResolver(): void
106107
$expected = ['foo' => 'baz'];
107108
$resolveFn = $objectType->getField('bar')->resolveFn;
108109
/** @var Argument $args */
109-
$args = $resolveFn(null, $expected);
110+
$args = $resolveFn(null, $expected, [], $this->createMock(ResolveInfo::class));
111+
110112
$this->assertInstanceOf(Argument::class, $args);
111113
$this->assertSame($expected, $args->getArrayCopy());
112114
}

0 commit comments

Comments
 (0)