@@ -815,13 +815,16 @@ func parseOperationDefinition(parser *Parser) (interface{}, error) {
815
815
if err != nil {
816
816
return nil , err
817
817
}
818
- _ , err = expect (parser , lexer .TokenKind [lexer .COLON ])
818
+ _ , colon , err := optional (parser , lexer .TokenKind [lexer .COLON ])
819
819
if err != nil {
820
820
return nil , err
821
821
}
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
+ }
825
828
}
826
829
annotations , err := parseAnnotations (parser )
827
830
if err != nil {
@@ -1383,6 +1386,14 @@ func expect(parser *Parser, kind int) (lexer.Token, error) {
1383
1386
return token , errors .NewSyntaxError (parser .Source , token .Start , descp )
1384
1387
}
1385
1388
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
+
1386
1397
// If the next token is a keyword with the given value, return that token after
1387
1398
// advancing the parser. Otherwise, do not change the parser state and return false.
1388
1399
func expectKeyWord (parser * Parser , value string ) (lexer.Token , error ) {
0 commit comments