diff --git a/src/main/antlr/GraphqlSDL.g4 b/src/main/antlr/GraphqlSDL.g4 index 58d15d7c43..9dd97dc29d 100644 --- a/src/main/antlr/GraphqlSDL.g4 +++ b/src/main/antlr/GraphqlSDL.g4 @@ -48,7 +48,7 @@ implementsInterfaces : IMPLEMENTS '&'? typeName+ | implementsInterfaces '&' typeName ; -fieldsDefinition : '{' fieldDefinition+ '}'; +fieldsDefinition : '{' fieldDefinition* '}'; fieldDefinition : description? name argumentsDefinition? ':' type directives?; diff --git a/src/test/groovy/graphql/parser/IDLParserTest.groovy b/src/test/groovy/graphql/parser/IDLParserTest.groovy index c40761c9ac..03aaf1fc8e 100644 --- a/src/test/groovy/graphql/parser/IDLParserTest.groovy +++ b/src/test/groovy/graphql/parser/IDLParserTest.groovy @@ -548,6 +548,30 @@ input Gun { extTypeDef.getFieldDefinitions().size() == 1 } + def "empty type definition with body"() { + + def input = """ + type EmptyType { + + } + + extend type EmptyType { + hero : String + } +""" + when: + def document = new Parser().parseDocument(input) + + then: + ObjectTypeDefinition typeDef = document.definitions[0] as ObjectTypeDefinition + typeDef.getName() == 'EmptyType' + typeDef.getFieldDefinitions().isEmpty() + + ObjectTypeExtensionDefinition extTypeDef = document.definitions[1] as ObjectTypeExtensionDefinition + extTypeDef.getName() == 'EmptyType' + extTypeDef.getFieldDefinitions().size() == 1 + } + def "type implements can have & character for extra names"() { def input = """