@@ -815,13 +815,16 @@ func parseOperationDefinition(parser *Parser) (interface{}, error) {
815815 if err != nil {
816816 return nil , err
817817 }
818- _ , err = expect (parser , lexer .TokenKind [lexer .COLON ])
818+ _ , colon , err := optional (parser , lexer .TokenKind [lexer .COLON ])
819819 if err != nil {
820820 return nil , err
821821 }
822- ttype , err := parseType (parser )
823- if err != nil {
824- return nil , err
822+ var ttype ast.Type = ast .NewNamed (nil , ast .NewName (nil , "void" ))
823+ if colon {
824+ ttype , err = parseType (parser )
825+ if err != nil {
826+ return nil , err
827+ }
825828 }
826829 annotations , err := parseAnnotations (parser )
827830 if err != nil {
@@ -1383,6 +1386,14 @@ func expect(parser *Parser, kind int) (lexer.Token, error) {
13831386 return token , errors .NewSyntaxError (parser .Source , token .Start , descp )
13841387}
13851388
1389+ func optional (parser * Parser , kind int ) (lexer.Token , bool , error ) {
1390+ token := parser .Token
1391+ if token .Kind == kind {
1392+ return token , true , advance (parser )
1393+ }
1394+ return token , false , nil
1395+ }
1396+
13861397// If the next token is a keyword with the given value, return that token after
13871398// advancing the parser. Otherwise, do not change the parser state and return false.
13881399func expectKeyWord (parser * Parser , value string ) (lexer.Token , error ) {
0 commit comments