Skip to content

Commit 44054b3

Browse files
committed
Enum value of TRUE breaks schema (#244)
1 parent 0e156a6 commit 44054b3

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

gen/com/intellij/lang/jsgraphql/GraphQLParser.java

Lines changed: 2 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/grammars/GraphQLParser.bnf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ operationType ::= 'query' | 'mutation' | 'subscription'
100100

101101
private description ::= quotedString
102102

103-
enumValue ::= !('true' | 'false' | 'null') identifier {methods=[nameIdentifier="identifier"] extends=value}
103+
enumValue ::= identifier {methods=[nameIdentifier="identifier"] extends=value}
104104

105105
arrayValue::= '[' arrayValueElement* ']' {pin=1 extends=value}
106106

src/main/com/intellij/lang/jsgraphql/ide/GraphQLValidationAnnotator.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ public void annotate(@NotNull PsiElement psiElement, @NotNull AnnotationHolder a
175175
}
176176
}
177177

178+
// valid enum value names according to spec
179+
if (psiElement instanceof GraphQLEnumValue) {
180+
final GraphQLIdentifier nameIdentifier = ((GraphQLEnumValue) psiElement).getNameIdentifier();
181+
final String enumValueName = nameIdentifier.getText();
182+
if ("true".equals(enumValueName) || "false".equals(enumValueName) || "null".equals(enumValueName)) {
183+
createErrorAnnotation(annotationHolder, nameIdentifier, "Enum values can not be named \"" + enumValueName + "\"");
184+
}
185+
}
186+
178187
// validation using graphql-java
179188
final AnnotationSession session = annotationHolder.getCurrentAnnotationSession();
180189
final PsiFile containingFile = psiElement.getContainingFile();

0 commit comments

Comments
 (0)