Skip to content

Commit 914d91e

Browse files
authored
Remove Utils::find(), Utils::every() and Utils::invariant() (#1082)
1 parent b49ffe9 commit 914d91e

22 files changed

+159
-268
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ You can find and compare releases at the [GitHub release page](https://github.co
111111
- Remove parameter `$options` from `ASTDefinitionBuilder`
112112
- Remove `FieldDefinition::create()` in favor of `new FieldDefinition()`
113113
- Remove `GraphQL\Exception\InvalidArgument`
114+
- Remove `Utils::find()`, `Utils::every()` and `Utils::invariant()`
114115

115116
## 14.11.5
116117

benchmarks/HugeSchemaBench.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ private function createLazySchema(): Schema
6767
return new Schema(
6868
SchemaConfig::create()
6969
->setQuery($this->schemaGenerator->buildQueryType())
70-
->setTypeLoader(function (string $name): Type {
71-
return $this->schemaGenerator->loadType($name);
72-
})
70+
->setTypeLoader(fn (string $name): Type => $this->schemaGenerator->loadType($name))
7371
);
7472
}
7573
}

benchmarks/Utils/SchemaGenerator.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ protected function createType(int $nestingLevel, ?string $typeName = null): Obje
7676

7777
$type = new ObjectType([
7878
'name' => $typeName,
79-
'fields' => function () use ($typeName, $nestingLevel): array {
80-
return $this->createTypeFields($typeName, $nestingLevel + 1);
81-
},
79+
'fields' => fn (): array => $this->createTypeFields($typeName, $nestingLevel + 1),
8280
]);
8381

8482
$this->objectTypes[$typeName] = $type;
@@ -128,15 +126,13 @@ protected function createTypeFields(string $typeName, int $nestingLevel): array
128126
'name' => $name,
129127
'type' => Type::listOf($type),
130128
'args' => $this->createFieldArgs($name, $typeName),
131-
'resolve' => static function (): array {
132-
return [
133-
'string1',
134-
'string2',
135-
'string3',
136-
'string4',
137-
'string5',
138-
];
139-
},
129+
'resolve' => static fn (): array => [
130+
'string1',
131+
'string2',
132+
'string3',
133+
'string4',
134+
'string5',
135+
],
140136
];
141137
}
142138

docs/data-fetching.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ Here is an example of **BlogStory** resolver for field **author** that uses defe
201201

202202
return new GraphQL\Deferred(function () use ($blogStory) {
203203
MyUserBuffer::loadBuffered();
204+
204205
return MyUserBuffer::get($blogStory['authorId']);
205206
});
206207
}

docs/getting-started.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ $queryType = new ObjectType([
5858
'args' => [
5959
'message' => Type::nonNull(Type::string()),
6060
],
61-
'resolve' => function ($rootValue, $args) {
62-
return $rootValue['prefix'] . $args['message'];
63-
}
61+
'resolve' => fn ($rootValue, $args) => $rootValue['prefix'] . $args['message'],
6462
],
6563
],
6664
]);

docs/schema-definition.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ $queryType = new ObjectType([
3737
'fields' => [
3838
'hello' => [
3939
'type' => Type::string(),
40-
'resolve' => function() {
41-
return 'Hello World!';
42-
}
40+
'resolve' => fn () => 'Hello World!',
4341
],
4442
'hero' => [
4543
'type' => $characterInterface,
@@ -48,9 +46,7 @@ $queryType = new ObjectType([
4846
'type' => $episodeEnum
4947
]
5048
],
51-
'resolve' => function ($rootValue, $args) {
52-
return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null);
53-
},
49+
'resolve' => fn ($rootValue, $args) => StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null),
5450
]
5551
]
5652
]);
@@ -64,8 +60,8 @@ $mutationType = new ObjectType([
6460
'episode' => $episodeEnum,
6561
'review' => $reviewInputObject
6662
],
67-
'resolve' => function($rootValue, $args) {
68-
// TODOC
63+
'resolve' => function ($rootValue, $args) {
64+
// TODO
6965
}
7066
]
7167
]

examples/00-hello-world/graphql.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
'args' => [
2626
'message' => ['type' => Type::string()],
2727
],
28-
'resolve' => static function ($rootValue, array $args): string {
29-
return $rootValue['prefix'] . $args['message'];
30-
},
28+
'resolve' => static fn ($rootValue, array $args): string => $rootValue['prefix'] . $args['message'],
3129
],
3230
],
3331
]);
@@ -41,9 +39,7 @@
4139
'x' => ['type' => Type::int()],
4240
'y' => ['type' => Type::int()],
4341
],
44-
'resolve' => static function ($calc, array $args): int {
45-
return $args['x'] + $args['y'];
46-
},
42+
'resolve' => static fn ($calc, array $args): int => $args['x'] + $args['y'],
4743
],
4844
],
4945
]);

examples/01-blog/Blog/Type/QueryType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ public function __construct()
6363
],
6464
'hello' => Type::string(),
6565
],
66-
'resolveField' => function ($rootValue, $args, $context, ResolveInfo $info) {
67-
return $this->{$info->fieldName}($rootValue, $args, $context, $info);
68-
},
66+
'resolveField' => fn ($rootValue, array $args, $context, ResolveInfo $info) => $this->{$info->fieldName}($rootValue, $args, $context, $info),
6967
]);
7068
}
7169

examples/03-standard-server/graphql.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
'args' => [
2626
'message' => ['type' => Type::string()],
2727
],
28-
'resolve' => static function (array $rootValue, array $args): string {
29-
return $rootValue['prefix'] . $args['message'];
30-
},
28+
'resolve' => static fn (array $rootValue, array $args): string => $rootValue['prefix'] . $args['message'],
3129
],
3230
],
3331
]);
@@ -41,9 +39,7 @@
4139
'x' => ['type' => Type::int()],
4240
'y' => ['type' => Type::int()],
4341
],
44-
'resolve' => static function (array $rootValue, array $args): int {
45-
return $args['x'] + $args['y'];
46-
},
42+
'resolve' => static fn (array $rootValue, array $args): int => $args['x'] + $args['y'],
4743
],
4844
],
4945
]);

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ parameters:
160160
count: 1
161161
path: src/Validator/Rules/OverlappingFieldsCanBeMerged.php
162162

163+
-
164+
message: "#^Instanceof between mixed and GraphQL\\\\Language\\\\AST\\\\NodeList will always evaluate to false\\.$#"
165+
count: 1
166+
path: tests/Language/VisitorTest.php
167+
163168
-
164169
message: "#^Method GraphQL\\\\Tests\\\\Language\\\\VisitorTest\\:\\:getNodeByPath\\(\\) return type with generic class GraphQL\\\\Language\\\\AST\\\\NodeList does not specify its types\\: T$#"
165170
count: 1

0 commit comments

Comments
 (0)