Skip to content

Commit 5860c16

Browse files
committed
Rename Type for Nodes (root) to ClassName
Next step in differentiate between types and class names
1 parent 967bd93 commit 5860c16

31 files changed

+90
-91
lines changed

src/Parser/Ast.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Jerowork\GraphqlAttributeSchema\Parser;
66

77
use Jerowork\GraphqlAttributeSchema\Parser\Node\Node;
8-
use Jerowork\GraphqlAttributeSchema\Parser\Node\Type;
98

109
final readonly class Ast
1110
{
@@ -31,10 +30,10 @@ public function getNodesByNodeType(string $nodeType): array
3130
return array_values(array_filter($this->nodes, fn($node) => $node instanceof $nodeType));
3231
}
3332

34-
public function getNodeByType(Type $type): ?Node
33+
public function getNodeByClassName(string $className): ?Node
3534
{
3635
foreach ($this->nodes as $node) {
37-
if (!$node->getType()->equals($type)) {
36+
if ($node->getClassName() !== $className) {
3837
continue;
3938
}
4039

src/Parser/Node/EnumNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
final readonly class EnumNode implements Node
88
{
99
/**
10+
* @param class-string $className
1011
* @param list<EnumValueNode> $cases
1112
*/
1213
public function __construct(
13-
public Type $type,
14+
public string $className,
1415
public string $name,
1516
public ?string $description,
1617
public array $cases,
1718
) {}
1819

19-
public function getType(): Type
20+
public function getClassName(): string
2021
{
21-
return $this->type;
22+
return $this->className;
2223
}
2324
}

src/Parser/Node/InputTypeNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
final readonly class InputTypeNode implements Node
1010
{
1111
/**
12+
* @param class-string $className
1213
* @param list<FieldNode> $fieldNodes
1314
*/
1415
public function __construct(
15-
public Type $type,
16+
public string $className,
1617
public string $name,
1718
public ?string $description,
1819
public array $fieldNodes,
1920
) {}
2021

21-
public function getType(): Type
22+
public function getClassName(): string
2223
{
23-
return $this->type;
24+
return $this->className;
2425
}
2526
}

src/Parser/Node/MutationNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
final readonly class MutationNode implements Node
1010
{
1111
/**
12+
* @param class-string $className
1213
* @param list<ArgNode> $argNodes
1314
*/
1415
public function __construct(
15-
public Type $type,
16+
public string $className,
1617
public string $name,
1718
public ?string $description,
1819
public array $argNodes,
@@ -21,8 +22,8 @@ public function __construct(
2122
public string $methodName,
2223
) {}
2324

24-
public function getType(): Type
25+
public function getClassName(): string
2526
{
26-
return $this->type;
27+
return $this->className;
2728
}
2829
}

src/Parser/Node/Node.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66

77
interface Node
88
{
9-
public function getType(): Type;
9+
/**
10+
* @return class-string
11+
*/
12+
public function getClassName(): string;
1013
}

src/Parser/Node/QueryNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
final readonly class QueryNode implements Node
1010
{
1111
/**
12+
* @param class-string $className
1213
* @param list<ArgNode> $argNodes
1314
*/
1415
public function __construct(
15-
public Type $type,
16+
public string $className,
1617
public string $name,
1718
public ?string $description,
1819
public array $argNodes,
@@ -21,8 +22,8 @@ public function __construct(
2122
public string $methodName,
2223
) {}
2324

24-
public function getType(): Type
25+
public function getClassName(): string
2526
{
26-
return $this->type;
27+
return $this->className;
2728
}
2829
}

src/Parser/Node/TypeNode.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,18 @@
99
final readonly class TypeNode implements Node
1010
{
1111
/**
12+
* @param class-string $className
1213
* @param list<FieldNode> $fieldNodes
1314
*/
1415
public function __construct(
15-
public Type $type,
16+
public string $className,
1617
public string $name,
1718
public ?string $description,
1819
public array $fieldNodes,
1920
) {}
2021

21-
public function getType(): Type
22+
public function getClassName(): string
2223
{
23-
return $this->type;
24+
return $this->className;
2425
}
2526
}

src/Parser/NodeParser/EnumNodeParser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Jerowork\GraphqlAttributeSchema\Parser\Node\EnumNode;
1010
use Jerowork\GraphqlAttributeSchema\Parser\Node\EnumValueNode;
1111
use Jerowork\GraphqlAttributeSchema\Parser\Node\Node;
12-
use Jerowork\GraphqlAttributeSchema\Parser\Node\Type;
1312
use ReflectionClass;
1413
use BackedEnum;
1514
use Override;
@@ -48,7 +47,7 @@ public function parse(ReflectionClass $class): Node
4847

4948
/** @var ReflectionClass<UnitEnum> $class */
5049
return new EnumNode(
51-
Type::createObject($className),
50+
$className,
5251
$this->retrieveNameForType($class, $attribute),
5352
$attribute->getDescription(),
5453
$this->getValues($class),

src/Parser/NodeParser/InputTypeNodeParser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Jerowork\GraphqlAttributeSchema\Attribute\InputType;
88
use Jerowork\GraphqlAttributeSchema\Parser\Node\InputTypeNode;
99
use Jerowork\GraphqlAttributeSchema\Parser\Node\Node;
10-
use Jerowork\GraphqlAttributeSchema\Parser\Node\Type;
1110
use Jerowork\GraphqlAttributeSchema\Parser\NodeParser\Child\ClassFieldNodesParser;
1211
use ReflectionClass;
1312
use Override;
@@ -33,7 +32,7 @@ public function parse(ReflectionClass $class): Node
3332
$attribute = $this->getClassAttribute($class, InputType::class);
3433

3534
return new InputTypeNode(
36-
Type::createObject($class->getName()),
35+
$class->getName(),
3736
$this->retrieveNameForType($class, $attribute),
3837
$attribute->getDescription(),
3938
$this->classFieldNodesParser->parse($class),

src/Parser/NodeParser/MutationNodeParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function parse(ReflectionClass $class): Node
4949
}
5050

5151
return new MutationNode(
52-
Type::createObject($class->getName()),
52+
$class->getName(),
5353
$this->retrieveNameForResolver($class, $attribute, self::RESOLVER_SUFFIX),
5454
$attribute->getDescription(),
5555
$this->methodArgNodesParser->parse($method),

0 commit comments

Comments
 (0)