Skip to content

Commit ceb6e94

Browse files
authored
Reorganize AST interfaces related to schema and type extensions (#1073)
1 parent 4f7db61 commit ceb6e94

18 files changed

+67
-43
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ You can find and compare releases at the [GitHub release page](https://github.co
4040
- `PromiseAdapter::all()` accepts `iterable`
4141
- Throw if `Introspection::fromSchema()` returns no data
4242
- Reorganize abstract class `ASTValidationContext` to interface `ValidationContext`
43+
- Reorganize AST interfaces related to schema and type extensions
4344

4445
### Added
4546

src/Language/AST/DefinitionNode.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/**
66
* export type DefinitionNode =
77
* | ExecutableDefinitionNode
8-
* | TypeSystemDefinitionNode;.
8+
* | TypeSystemDefinitionNode
9+
* | TypeSystemExtensionNode;.
910
*/
1011
interface DefinitionNode
1112
{

src/Language/AST/SchemaTypeExtensionNode.php renamed to src/Language/AST/SchemaExtensionNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace GraphQL\Language\AST;
44

5-
class SchemaTypeExtensionNode extends Node implements TypeExtensionNode
5+
class SchemaExtensionNode extends Node implements TypeSystemExtensionNode
66
{
77
public string $kind = NodeKind::SCHEMA_EXTENSION;
88

src/Language/AST/TypeDefinitionNode.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* | UnionTypeDefinitionNode
1010
* | EnumTypeDefinitionNode
1111
* | InputObjectTypeDefinitionNode.
12+
*
13+
* @property NameNode $name
1214
*/
1315
interface TypeDefinitionNode extends TypeSystemDefinitionNode
1416
{

src/Language/AST/TypeExtensionNode.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
* | UnionTypeExtensionNode
1111
* | EnumTypeExtensionNode
1212
* | InputObjectTypeExtensionNode;.
13+
*
14+
* @property NameNode $name
1315
*/
14-
interface TypeExtensionNode extends TypeSystemDefinitionNode
16+
interface TypeExtensionNode extends TypeSystemExtensionNode
1517
{
1618
}

src/Language/AST/TypeSystemDefinitionNode.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
* export type TypeSystemDefinitionNode =
77
* | SchemaDefinitionNode
88
* | TypeDefinitionNode
9-
* | TypeExtensionNode
109
* | DirectiveDefinitionNode.
11-
*
12-
* @property NameNode $name
1310
*/
1411
interface TypeSystemDefinitionNode extends DefinitionNode
1512
{
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace GraphQL\Language\AST;
4+
5+
/**
6+
* export type TypeSystemExtensionNode = SchemaExtensionNode | TypeExtensionNode;.
7+
*/
8+
interface TypeSystemExtensionNode extends DefinitionNode
9+
{
10+
}

src/Language/Parser.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
4646
use GraphQL\Language\AST\ScalarTypeExtensionNode;
4747
use GraphQL\Language\AST\SchemaDefinitionNode;
48-
use GraphQL\Language\AST\SchemaTypeExtensionNode;
48+
use GraphQL\Language\AST\SchemaExtensionNode;
4949
use GraphQL\Language\AST\SelectionNode;
5050
use GraphQL\Language\AST\SelectionSetNode;
5151
use GraphQL\Language\AST\StringValueNode;
5252
use GraphQL\Language\AST\TypeExtensionNode;
5353
use GraphQL\Language\AST\TypeNode;
5454
use GraphQL\Language\AST\TypeSystemDefinitionNode;
55+
use GraphQL\Language\AST\TypeSystemExtensionNode;
5556
use GraphQL\Language\AST\UnionTypeDefinitionNode;
5657
use GraphQL\Language\AST\UnionTypeExtensionNode;
5758
use GraphQL\Language\AST\ValueNode;
@@ -161,7 +162,7 @@
161162
* @method static InputObjectTypeDefinitionNode inputObjectTypeDefinition(Source|string $source, bool[] $options = [])
162163
* @method static NodeList<InputValueDefinitionNode> inputFieldsDefinition(Source|string $source, bool[] $options = [])
163164
* @method static TypeExtensionNode typeExtension(Source|string $source, bool[] $options = [])
164-
* @method static SchemaTypeExtensionNode schemaTypeExtension(Source|string $source, bool[] $options = [])
165+
* @method static SchemaExtensionNode schemaTypeExtension(Source|string $source, bool[] $options = [])
165166
* @method static ScalarTypeExtensionNode scalarTypeExtension(Source|string $source, bool[] $options = [])
166167
* @method static ObjectTypeExtensionNode objectTypeExtension(Source|string $source, bool[] $options = [])
167168
* @method static InterfaceTypeExtensionNode interfaceTypeExtension(Source|string $source, bool[] $options = [])
@@ -508,10 +509,12 @@ private function parseDefinition(): DefinitionNode
508509
case 'union':
509510
case 'enum':
510511
case 'input':
511-
case 'extend':
512512
case 'directive':
513513
// Note: The schema definition language is an experimental addition.
514514
return $this->parseTypeSystemDefinition();
515+
516+
case 'extend':
517+
return $this->parseTypeSystemExtension();
515518
}
516519
} elseif ($this->peek(Token::BRACE_L)) {
517520
return $this->parseExecutableDefinition();
@@ -1055,9 +1058,6 @@ private function parseTypeSystemDefinition(): TypeSystemDefinitionNode
10551058
case 'input':
10561059
return $this->parseInputObjectTypeDefinition();
10571060

1058-
case 'extend':
1059-
return $this->parseTypeExtension();
1060-
10611061
case 'directive':
10621062
return $this->parseDirectiveDefinition();
10631063
}
@@ -1404,9 +1404,9 @@ function (): InputValueDefinitionNode {
14041404
}
14051405

14061406
/**
1407-
* @return TypeExtensionNode&Node
1407+
* @return TypeSystemExtensionNode&Node
14081408
*/
1409-
private function parseTypeExtension(): TypeExtensionNode
1409+
private function parseTypeSystemExtension(): TypeSystemExtensionNode
14101410
{
14111411
$keywordToken = $this->lexer->lookahead();
14121412

@@ -1438,7 +1438,7 @@ private function parseTypeExtension(): TypeExtensionNode
14381438
throw $this->unexpected($keywordToken);
14391439
}
14401440

1441-
private function parseSchemaTypeExtension(): SchemaTypeExtensionNode
1441+
private function parseSchemaTypeExtension(): SchemaExtensionNode
14421442
{
14431443
$start = $this->lexer->token;
14441444
$this->expectKeyword('extend');
@@ -1456,7 +1456,7 @@ private function parseSchemaTypeExtension(): SchemaTypeExtensionNode
14561456
$this->unexpected();
14571457
}
14581458

1459-
return new SchemaTypeExtensionNode([
1459+
return new SchemaExtensionNode([
14601460
'directives' => $directives,
14611461
'operationTypes' => $operationTypes,
14621462
'loc' => $this->loc($start),

src/Language/Printer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
4343
use GraphQL\Language\AST\ScalarTypeExtensionNode;
4444
use GraphQL\Language\AST\SchemaDefinitionNode;
45-
use GraphQL\Language\AST\SchemaTypeExtensionNode;
45+
use GraphQL\Language\AST\SchemaExtensionNode;
4646
use GraphQL\Language\AST\SelectionSetNode;
4747
use GraphQL\Language\AST\StringValueNode;
4848
use GraphQL\Language\AST\UnionTypeDefinitionNode;
@@ -389,7 +389,7 @@ protected function p(?Node $node, bool $isDescription = false): string
389389
' '
390390
);
391391

392-
case $node instanceof SchemaTypeExtensionNode:
392+
case $node instanceof SchemaExtensionNode:
393393
return $this->join(
394394
[
395395
'extend schema',

src/Type/Schema.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use GraphQL\Error\InvariantViolation;
88
use GraphQL\GraphQL;
99
use GraphQL\Language\AST\SchemaDefinitionNode;
10-
use GraphQL\Language\AST\SchemaTypeExtensionNode;
10+
use GraphQL\Language\AST\SchemaExtensionNode;
1111
use GraphQL\Type\Definition\AbstractType;
1212
use GraphQL\Type\Definition\Directive;
1313
use GraphQL\Type\Definition\ImplementingType;
@@ -70,7 +70,7 @@ class Schema
7070
/** @var array<int, Error> */
7171
private array $validationErrors;
7272

73-
/** @var array<int, SchemaTypeExtensionNode> */
73+
/** @var array<int, SchemaExtensionNode> */
7474
public array $extensionASTNodes = [];
7575

7676
/**

0 commit comments

Comments
 (0)