Skip to content

Commit ea58a4e

Browse files
authored
Merge pull request #613 from ste93cry/fix/enum-value-description-wrong-graphql-ast-parsing
Fix parsing of the descriptions of the enum values when using GraphQL schema file
2 parents 8e56bfb + 975922d commit ea58a4e

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

src/Config/Parser/GraphQL/ASTConverter/EnumNode.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ class EnumNode implements NodeInterface
88
{
99
public static function toConfig(Node $node)
1010
{
11-
$config = [
12-
'description' => DescriptionNode::toConfig($node),
13-
];
14-
1511
$values = [];
12+
1613
foreach ($node->values as $value) {
1714
$values[$value->name->value] = [
18-
'description' => DescriptionNode::toConfig($node),
15+
'description' => DescriptionNode::toConfig($value),
1916
'value' => $value->name->value,
2017
];
2118

2219
$directiveConfig = DirectiveNode::toConfig($value);
20+
2321
if (isset($directiveConfig['deprecationReason'])) {
2422
$values[$value->name->value]['deprecationReason'] = $directiveConfig['deprecationReason'];
2523
}
2624
}
27-
$config['values'] = $values;
2825

2926
return [
3027
'type' => 'enum',
31-
'config' => $config,
28+
'config' => [
29+
'description' => DescriptionNode::toConfig($node),
30+
'values' => $values,
31+
],
3232
];
3333
}
3434
}

tests/Config/Parser/fixtures/graphql/schema-0.11.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Starship {
1616

1717
enum Episode {
1818
NEWHOPE
19+
# Star Wars: Episode V – The Empire Strikes Back
1920
EMPIRE
2021
JEDI @deprecated
2122
}

tests/Config/Parser/fixtures/graphql/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type Starship {
1616

1717
enum Episode {
1818
NEWHOPE
19+
"""Star Wars: Episode V – The Empire Strikes Back"""
1920
EMPIRE
2021
JEDI @deprecated
2122
}

tests/Config/Parser/fixtures/graphql/schema.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,14 @@
5656
'config' => [
5757
'description' => null,
5858
'values' => [
59-
'NEWHOPE' => ['description' => null, 'value' => 'NEWHOPE'],
60-
'EMPIRE' => ['description' => null, 'value' => 'EMPIRE'],
59+
'NEWHOPE' => [
60+
'description' => null,
61+
'value' => 'NEWHOPE',
62+
],
63+
'EMPIRE' => [
64+
'description' => 'Star Wars: Episode V – The Empire Strikes Back',
65+
'value' => 'EMPIRE',
66+
],
6167
'JEDI' => [
6268
'description' => null,
6369
'value' => 'JEDI',

0 commit comments

Comments
 (0)