Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions language/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ func (parser *Parser) description() (string, error) {
text := ""
isBody := false
token := parser.lookahead
for token.Type == DESCRIPTION {
text += strings.Trim(token.Val[2:], " ")
for token.Type == STRING {
text += strings.Trim(token.Val, " ")
if isBody {
text += " "
} else {
isBody = true
}
err := parser.match(DESCRIPTION)
err := parser.match(STRING)
if err != nil {
return text, err
}
Expand Down
24 changes: 23 additions & 1 deletion language/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package language
import (
//"encoding/json"
"fmt"
. "github.com/smartystreets/goconvey/convey"
"strings"
"testing"
"unicode/utf8"

. "github.com/smartystreets/goconvey/convey"
)

var KITCHEN_SINK = `
Expand Down Expand Up @@ -366,6 +367,27 @@ fragment MissingOn Type`,
So(result.Definitions[0].(*OperationDefinition).SelectionSet.Selections[0].(*Field).ArgumentIndex["arg"].Value.(*String).Value, ShouldEqual, "Has a \u0A0A multi-byte character.")
})

Convey("parses single quote definitions", func() {
result, err = parser.Parse(&ParseParams{
Source: `
"This is a type definition"
type TestType {
"This is a field definition"
a: String

"This is a parameterized field definition"
b(id: IDENT!): String
}
`,
NoSource: true,
})
So(err, ShouldEqual, nil)

So(result.Definitions[0].(*ObjectTypeDefinition).Description, ShouldEqual, "This is a type definition")
So(result.Definitions[0].(*ObjectTypeDefinition).Fields[0].Description, ShouldEqual, "This is a field definition")
So(result.Definitions[0].(*ObjectTypeDefinition).Fields[1].Description, ShouldEqual, "This is a parameterized field definition")
})

Convey("parses kitchen sick", func() {
_, err := parser.Parse(&ParseParams{
Source: KITCHEN_SINK,
Expand Down