func parseObjectField(parser *Parser, isConst bool, fieldNames map[string]bool) (*ast.ObjectField, string, error) { start := parser.Token.Start name, err := parseName(parser) if err != nil { return nil, "", err } fieldName := name.Value if _, ok := fieldNames[fieldName]; ok { descp := fmt.Sprintf("Duplicate input object field %v.", fieldName) return nil, "", gqlerrors.NewSyntaxError(parser.Source, start, descp) } _, err = expect(parser, lexer.TokenKind[lexer.COLON]) if err != nil { return nil, "", err } value, err := parseValueLiteral(parser, isConst) if err != nil { return nil, "", err } return ast.NewObjectField(&ast.ObjectField{ Name: name, Value: value, Loc: loc(parser, start), }), fieldName, nil }
/** * ObjectField[Const] : Name : Value[?Const] */ func parseObjectField(parser *Parser, isConst bool) (*ast.ObjectField, error) { start := parser.Token.Start name, err := parseName(parser) if err != nil { return nil, err } _, err = expect(parser, lexer.TokenKind[lexer.COLON]) if err != nil { return nil, err } value, err := parseValueLiteral(parser, isConst) if err != nil { return nil, err } return ast.NewObjectField(&ast.ObjectField{ Name: name, Value: value, Loc: loc(parser, start), }), nil }