Skip to content

Commit 5a3c970

Browse files
committed
Simplify applied directives to DirectiveNode arrays only
1 parent 6872ccc commit 5a3c970

13 files changed

+30
-81
lines changed

src/Type/Definition/Argument.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use GraphQL\Language\AST\DirectiveNode;
77
use GraphQL\Language\AST\InputValueDefinitionNode;
88
use GraphQL\Type\Schema;
9-
use GraphQL\Utils\AppliedDirectives;
109
use GraphQL\Utils\Utils;
1110

1211
/**
@@ -17,7 +16,7 @@
1716
* defaultValue?: mixed,
1817
* description?: string|null,
1918
* deprecationReason?: string|null,
20-
* directives?: iterable<DirectiveNode>|null,
19+
* directives?: array<DirectiveNode>|null,
2120
* astNode?: InputValueDefinitionNode|null
2221
* }
2322
* @phpstan-type ArgumentConfig array{
@@ -26,7 +25,7 @@
2625
* defaultValue?: mixed,
2726
* description?: string|null,
2827
* deprecationReason?: string|null,
29-
* directives?: iterable<DirectiveNode>|null,
28+
* directives?: array<DirectiveNode>|null,
3029
* astNode?: InputValueDefinitionNode|null
3130
* }
3231
* @phpstan-type ArgumentListConfig iterable<ArgumentConfig|ArgumentType>|iterable<UnnamedArgumentConfig>
@@ -66,7 +65,7 @@ public function __construct(array $config)
6665
$this->deprecationReason = $config['deprecationReason'] ?? null;
6766
// Do nothing for type, it is lazy loaded in getType()
6867
$this->astNode = $config['astNode'] ?? null;
69-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
68+
$this->directives = $config['directives'] ?? [];
7069

7170
$this->config = $config;
7271
}

src/Type/Definition/CustomScalarType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* serialize?: callable(mixed): mixed,
2020
* parseValue: callable(mixed): mixed,
2121
* parseLiteral: callable(ValueNode&Node, array<string, mixed>|null): mixed,
22-
* directives?: iterable<DirectiveNode>|null,
22+
* directives?: array<DirectiveNode>|null,
2323
* astNode?: ScalarTypeDefinitionNode|null,
2424
* extensionASTNodes?: array<ScalarTypeExtensionNode>|null
2525
* }
@@ -29,7 +29,7 @@
2929
* serialize: callable(mixed): mixed,
3030
* parseValue?: callable(mixed): mixed,
3131
* parseLiteral?: callable(ValueNode&Node, array<string, mixed>|null): mixed,
32-
* directives?: iterable<DirectiveNode>|null,
32+
* directives?: array<DirectiveNode>|null,
3333
* astNode?: ScalarTypeDefinitionNode|null,
3434
* extensionASTNodes?: array<ScalarTypeExtensionNode>|null
3535
* }

src/Type/Definition/EnumType.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use GraphQL\Language\AST\EnumValueNode;
1313
use GraphQL\Language\AST\Node;
1414
use GraphQL\Language\Printer;
15-
use GraphQL\Utils\AppliedDirectives;
1615
use GraphQL\Utils\MixedStore;
1716
use GraphQL\Utils\Utils;
1817

@@ -24,15 +23,15 @@
2423
* value?: mixed,
2524
* deprecationReason?: string|null,
2625
* description?: string|null,
27-
* directives?: iterable<DirectiveNode>|null,
26+
* directives?: array<DirectiveNode>|null,
2827
* astNode?: EnumValueDefinitionNode|null
2928
* }
3029
* @phpstan-type EnumValues iterable<string, PartialEnumValueConfig>|iterable<string, mixed>|iterable<int, string>
3130
* @phpstan-type EnumTypeConfig array{
3231
* name?: string|null,
3332
* description?: string|null,
3433
* values: EnumValues|callable(): EnumValues,
35-
* directives?: iterable<DirectiveNode>|null,
34+
* directives?: array<DirectiveNode>|null,
3635
* astNode?: EnumTypeDefinitionNode|null,
3736
* extensionASTNodes?: array<EnumTypeExtensionNode>|null
3837
* }
@@ -80,7 +79,7 @@ public function __construct(array $config)
8079
$this->description = $config['description'] ?? null;
8180
$this->astNode = $config['astNode'] ?? null;
8281
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
83-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
82+
$this->directives = $config['directives'] ?? [];
8483

8584
$this->config = $config;
8685
}

src/Type/Definition/EnumValueDefinition.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
use GraphQL\Error\InvariantViolation;
66
use GraphQL\Language\AST\DirectiveNode;
77
use GraphQL\Language\AST\EnumValueDefinitionNode;
8-
use GraphQL\Utils\AppliedDirectives;
98

109
/**
1110
* @phpstan-type EnumValueConfig array{
1211
* name: string,
1312
* value?: mixed,
1413
* deprecationReason?: string|null,
1514
* description?: string|null,
16-
* directives?: iterable<DirectiveNode>|null,
15+
* directives?: array<DirectiveNode>|null,
1716
* astNode?: EnumValueDefinitionNode|null
1817
* }
1918
*/
@@ -48,7 +47,7 @@ public function __construct(array $config)
4847
$this->deprecationReason = $config['deprecationReason'] ?? null;
4948
$this->description = $config['description'] ?? null;
5049
$this->astNode = $config['astNode'] ?? null;
51-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
50+
$this->directives = $config['directives'] ?? [];
5251

5352
$this->config = $config;
5453
}

src/Type/Definition/FieldDefinition.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use GraphQL\Language\AST\DirectiveNode;
88
use GraphQL\Language\AST\FieldDefinitionNode;
99
use GraphQL\Type\Schema;
10-
use GraphQL\Utils\AppliedDirectives;
1110
use GraphQL\Utils\Utils;
1211

1312
/**
@@ -29,7 +28,7 @@
2928
* description?: string|null,
3029
* visible?: VisibilityFn|bool,
3130
* deprecationReason?: string|null,
32-
* directives?: iterable<DirectiveNode>|null,
31+
* directives?: array<DirectiveNode>|null,
3332
* astNode?: FieldDefinitionNode|null,
3433
* complexity?: ComplexityFn|null
3534
* }
@@ -41,7 +40,7 @@
4140
* description?: string|null,
4241
* visible?: VisibilityFn|bool,
4342
* deprecationReason?: string|null,
44-
* directives?: iterable<DirectiveNode>|null,
43+
* directives?: array<DirectiveNode>|null,
4544
* astNode?: FieldDefinitionNode|null,
4645
* complexity?: ComplexityFn|null
4746
* }
@@ -131,7 +130,7 @@ public function __construct(array $config)
131130
$this->visible = $config['visible'] ?? true;
132131
$this->deprecationReason = $config['deprecationReason'] ?? null;
133132
$this->astNode = $config['astNode'] ?? null;
134-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
133+
$this->directives = $config['directives'] ?? [];
135134
$this->complexityFn = $config['complexity'] ?? null;
136135

137136
$this->config = $config;

src/Type/Definition/InputObjectField.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use GraphQL\Language\AST\DirectiveNode;
77
use GraphQL\Language\AST\InputValueDefinitionNode;
88
use GraphQL\Type\Schema;
9-
use GraphQL\Utils\AppliedDirectives;
109
use GraphQL\Utils\Utils;
1110

1211
/**
@@ -17,7 +16,7 @@
1716
* defaultValue?: mixed,
1817
* description?: string|null,
1918
* deprecationReason?: string|null,
20-
* directives?: iterable<DirectiveNode>|null,
19+
* directives?: array<DirectiveNode>|null,
2120
* astNode?: InputValueDefinitionNode|null
2221
* }
2322
* @phpstan-type UnnamedInputObjectFieldConfig array{
@@ -26,7 +25,7 @@
2625
* defaultValue?: mixed,
2726
* description?: string|null,
2827
* deprecationReason?: string|null,
29-
* directives?: iterable<DirectiveNode>|null,
28+
* directives?: array<DirectiveNode>|null,
3029
* astNode?: InputValueDefinitionNode|null
3130
* }
3231
*/
@@ -65,7 +64,7 @@ public function __construct(array $config)
6564
$this->deprecationReason = $config['deprecationReason'] ?? null;
6665
// Do nothing for type, it is lazy loaded in getType()
6766
$this->astNode = $config['astNode'] ?? null;
68-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
67+
$this->directives = $config['directives'] ?? [];
6968

7069
$this->config = $config;
7170
}

src/Type/Definition/InputObjectType.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use GraphQL\Language\AST\DirectiveNode;
88
use GraphQL\Language\AST\InputObjectTypeDefinitionNode;
99
use GraphQL\Language\AST\InputObjectTypeExtensionNode;
10-
use GraphQL\Utils\AppliedDirectives;
1110
use GraphQL\Utils\Utils;
1211

1312
/**
@@ -23,7 +22,7 @@
2322
* isOneOf?: bool|null,
2423
* fields: iterable<FieldConfig>|callable(): iterable<FieldConfig>,
2524
* parseValue?: ParseValueFn|null,
26-
* directives?: iterable<DirectiveNode>|null,
25+
* directives?: array<DirectiveNode>|null,
2726
* astNode?: InputObjectTypeDefinitionNode|null,
2827
* extensionASTNodes?: array<InputObjectTypeExtensionNode>|null
2928
* }
@@ -69,7 +68,7 @@ public function __construct(array $config)
6968
$this->parseValue = $config['parseValue'] ?? null;
7069
$this->astNode = $config['astNode'] ?? null;
7170
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
72-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
71+
$this->directives = $config['directives'] ?? [];
7372

7473
$this->config = $config;
7574
}

src/Type/Definition/InterfaceType.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use GraphQL\Language\AST\DirectiveNode;
88
use GraphQL\Language\AST\InterfaceTypeDefinitionNode;
99
use GraphQL\Language\AST\InterfaceTypeExtensionNode;
10-
use GraphQL\Utils\AppliedDirectives;
1110
use GraphQL\Utils\Utils;
1211

1312
/**
@@ -23,7 +22,7 @@
2322
* interfaces?: iterable<InterfaceTypeReference>|callable(): iterable<InterfaceTypeReference>,
2423
* resolveType?: ResolveType|null,
2524
* resolveValue?: ResolveValue|null,
26-
* directives?: iterable<DirectiveNode>|null,
25+
* directives?: array<DirectiveNode>|null,
2726
* astNode?: InterfaceTypeDefinitionNode|null,
2827
* extensionASTNodes?: array<InterfaceTypeExtensionNode>|null
2928
* }
@@ -56,7 +55,7 @@ public function __construct(array $config)
5655
$this->description = $config['description'] ?? null;
5756
$this->astNode = $config['astNode'] ?? null;
5857
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
59-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
58+
$this->directives = $config['directives'] ?? [];
6059

6160
$this->config = $config;
6261
}

src/Type/Definition/ObjectType.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use GraphQL\Language\AST\DirectiveNode;
1010
use GraphQL\Language\AST\ObjectTypeDefinitionNode;
1111
use GraphQL\Language\AST\ObjectTypeExtensionNode;
12-
use GraphQL\Utils\AppliedDirectives;
1312
use GraphQL\Utils\Utils;
1413

1514
/**
@@ -59,7 +58,7 @@
5958
* fields: (callable(): iterable<mixed>)|iterable<mixed>,
6059
* interfaces?: iterable<InterfaceTypeReference>|callable(): iterable<InterfaceTypeReference>,
6160
* isTypeOf?: (callable(mixed $objectValue, mixed $context, ResolveInfo $resolveInfo): (bool|Deferred|null))|null,
62-
* directives?: iterable<DirectiveNode>|null,
61+
* directives?: array<DirectiveNode>|null,
6362
* astNode?: ObjectTypeDefinitionNode|null,
6463
* extensionASTNodes?: array<ObjectTypeExtensionNode>|null
6564
* }
@@ -108,7 +107,7 @@ public function __construct(array $config)
108107
$this->argsMapper = $config['argsMapper'] ?? null;
109108
$this->astNode = $config['astNode'] ?? null;
110109
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
111-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
110+
$this->directives = $config['directives'] ?? [];
112111

113112
$this->config = $config;
114113
}

src/Type/Definition/ScalarType.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use GraphQL\Language\AST\DirectiveNode;
77
use GraphQL\Language\AST\ScalarTypeDefinitionNode;
88
use GraphQL\Language\AST\ScalarTypeExtensionNode;
9-
use GraphQL\Utils\AppliedDirectives;
109
use GraphQL\Utils\Utils;
1110

1211
/**
@@ -30,7 +29,7 @@
3029
* @phpstan-type ScalarConfig array{
3130
* name?: string|null,
3231
* description?: string|null,
33-
* directives?: iterable<DirectiveNode>|null,
32+
* directives?: array<DirectiveNode>|null,
3433
* astNode?: ScalarTypeDefinitionNode|null,
3534
* extensionASTNodes?: array<ScalarTypeExtensionNode>|null
3635
* }
@@ -61,7 +60,7 @@ public function __construct(array $config = [])
6160
$this->description = $config['description'] ?? $this->description ?? null;
6261
$this->astNode = $config['astNode'] ?? null;
6362
$this->extensionASTNodes = $config['extensionASTNodes'] ?? [];
64-
$this->directives = AppliedDirectives::normalize($config['directives'] ?? null);
63+
$this->directives = $config['directives'] ?? [];
6564

6665
$this->config = $config;
6766
}

0 commit comments

Comments
 (0)