diff --git a/ast/definitions.go b/ast/definitions.go index 32da534..ae34ac3 100644 --- a/ast/definitions.go +++ b/ast/definitions.go @@ -271,14 +271,18 @@ type EnumValueDefinition struct { BaseNode Name *Name `json:"name"` Description *StringValue `json:"description,omitempty"` // Optional + Index *IntValue `json:"index"` + Display *StringValue `json:"display,omitempty"` // Optional AnnotatedNode } -func NewEnumValueDefinition(loc *Location, name *Name, description *StringValue, annotations []*Annotation) *EnumValueDefinition { +func NewEnumValueDefinition(loc *Location, name *Name, description *StringValue, index *IntValue, display *StringValue, annotations []*Annotation) *EnumValueDefinition { return &EnumValueDefinition{ BaseNode: BaseNode{kinds.EnumValueDefinition, loc}, Name: name, Description: description, + Index: index, + Display: display, AnnotatedNode: AnnotatedNode{annotations}, } } diff --git a/parser/parser.go b/parser/parser.go index 06a84ad..f112102 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -1178,14 +1178,34 @@ func parseEnumValueDefinition(parser *Parser) (interface{}, error) { if err != nil { return nil, err } + _, err = expect(parser, lexer.TokenKind[lexer.EQUALS]) + if err != nil { + return nil, err + } + token, err := expect(parser, lexer.TokenKind[lexer.INT]) + if err != nil { + return nil, err + } + indexValue, err := strconv.Atoi(token.Value) + index := ast.NewIntValue(loc(parser, token.Start), indexValue) annotations, err := parseAnnotations(parser) if err != nil { return nil, err } + var display *ast.StringValue + if _, ok, err := optionalKeyWord(parser, "as"); err != nil { + return nil, err + } else if ok { + if display, err = parseStringLiteral(parser); err != nil { + return nil, err + } + } return ast.NewEnumValueDefinition( loc(parser, start), name, description, + index, + display, annotations, ), nil }