Skip to content

Commit

Permalink
Equals sign in union is optional according to spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennor authored and KMatysiewicz committed Dec 16, 2020
1 parent ba29b76 commit 5af2c39
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions language/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ func parseInterfaceTypeDefinition(parser *Parser) (ast.Node, error) {
}

/**
* UnionTypeDefinition : Description? union Name Directives? = UnionMembers
* UnionTypeDefinition : Description? union Name Directives? UnionMembers?
*/
func parseUnionTypeDefinition(parser *Parser) (ast.Node, error) {
start := parser.Token.Start
Expand All @@ -1211,13 +1211,16 @@ func parseUnionTypeDefinition(parser *Parser) (ast.Node, error) {
if err != nil {
return nil, err
}
_, err = expect(parser, lexer.EQUALS)
if err != nil {
return nil, err
}
types, err := parseUnionMembers(parser)
if err != nil {
return nil, err
var types []*ast.Named
if parser.Token.Kind == lexer.EQUALS {
err = advance(parser)
if err != nil {
return nil, err
}
types, err = parseUnionMembers(parser)
if err != nil {
return nil, err
}
}
return ast.NewUnionDefinition(&ast.UnionDefinition{
Name: name,
Expand All @@ -1229,9 +1232,11 @@ func parseUnionTypeDefinition(parser *Parser) (ast.Node, error) {
}

/**
* UnionMembers :
* UnionMembers : = UnionMemberTypes
*
* UnionMemberTypes
* - NamedType
* - UnionMembers | NamedType
* - UnionMemberTypes | NamedType
*/
func parseUnionMembers(parser *Parser) ([]*ast.Named, error) {
members := []*ast.Named{}
Expand Down

0 comments on commit 5af2c39

Please sign in to comment.