From ec4e3110bc04657df4a04d94af35df8748aa7b03 Mon Sep 17 00:00:00 2001 From: TiPoK Date: Sun, 27 May 2018 12:31:44 +0200 Subject: [PATCH 1/2] added a test for emty types with body --- .../graphql/parser/IDLParserTest.groovy | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 = """ From 838c9dc4abc2d20011c7e2c057692c5330879eec Mon Sep 17 00:00:00 2001 From: TiPoK Date: Sun, 27 May 2018 15:38:55 +0200 Subject: [PATCH 2/2] changed to allow empty bodies for type def --- src/main/antlr/GraphqlSDL.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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?;