FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Disallow descriptions on root operation mappings by andimarek · Pull Request #4393 · graphql-java/graphql-java · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .g4  (1) .groovy  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion src/main/antlr/GraphqlSDL.g4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ schemaExtension :
EXTEND SCHEMA directives
;

operationTypeDefinition : description? operationType ':' typeName;
operationTypeDefinition : operationType ':' typeName;

typeDefinition:
scalarTypeDefinition |
Expand Down
61 changes: 60 additions & 1 deletion src/test/groovy/graphql/parser/SDLParserTest.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,66 @@ schema @d1 @d2 {
isEqual(document.definitions[0], schema.build())
}

def "schema definition can have a description"() {
given:
def input = '''
"Schema description"
schema {
query: OpType1
}
'''

when:
def document = new Parser().parseDocument(input)

then:
document.definitions.size() == 1
SchemaDefinition schemaDefinition = document.definitions[0] as SchemaDefinition
schemaDefinition.description.content == "Schema description"
schemaDefinition.operationTypeDefinitions[0].name == "query"
schemaDefinition.operationTypeDefinitions[0].typeName.name == "OpType1"
}

def "schema root operation type mapping cannot have a description"() {
given:
def input = '''
schema {
"Query root operation mapping"
query: Query
}
'''

when:
new Parser().parseDocument(input)

then:
def e = thrown(InvalidSyntaxException)

e.location.line == 3
e.location.column == 5
e.offendingToken == '"Query root operation mapping"'
}

def "schema extension root operation type mapping cannot have a description"() {
given:
def input = '''
extend schema {
"Query root operation mapping"
query: Query
}
'''

when:
new Parser().parseDocument(input)

then:
def e = thrown(InvalidSyntaxException)

e.location.line == 3
e.location.column == 5
e.offendingToken == '"Query root operation mapping"'
}

def "extend schema"() {
given:
def input = """
Expand Down Expand Up @@ -1069,4 +1129,3 @@ directive @myDirective on
e.offendingToken == "<EOF>"
}
}


Back | FazBrowse Home | New Git URL