-
Notifications
You must be signed in to change notification settings - Fork 135
Open
Description
What happened?
Columns are negative for fields with multi-line comments.
The below test fails with the following errors:
Error: Not equal:
expected: 8
actual : -8
Test: TestSchemaParser/schema_with_multi-line_description
Messages: wrong column for 'me'
and
Error: Not equal:
expected: 8
actual : -9
Test: TestSchemaParser/schema_with_multi-line_description
Messages: wrong column for 'name'
package main
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/vektah/gqlparser/v2/ast"
"github.com/vektah/gqlparser/v2/parser"
)
func TestSchemaParser(t *testing.T) {
t.Run("schema with multi-line description", func(t *testing.T) {
schema, parseErr := parser.ParseSchema(&ast.Source{
Input: `type User {
"""
name
"""
name: String!
}
"""
some
description
"""
type query {
"""
me
"""
me: User!
}
`,
})
assert.Nil(t, parseErr)
queryType := schema.Definitions.ForName("query")
for _, field := range queryType.Fields {
assert.Equal(t, "me", field.Name)
assert.Equal(t, 14, field.Position.Line)
assert.Equal(t, 8, field.Position.Column, "wrong column for 'me'")
}
assert.Equal(t, 11, queryType.Position.Line)
assert.Equal(t, 9, queryType.Position.Column)
userType := schema.Definitions.ForName("User")
for _, field := range userType.Fields {
assert.Equal(t, "name", field.Name)
assert.Equal(t, 4, field.Position.Line)
assert.Equal(t, 8, field.Position.Column, "wrong column for 'name'")
}
assert.Equal(t, 1, userType.Position.Line)
assert.Equal(t, 6, userType.Position.Column)
})
}
What did you expect?
Columns should not be negative for fields with multiline comments
Minimal graphql.schema and models to reproduce
See above test case
versions
go list -m github.com/vektah/gqlparser/v2
? v2.4.7go version
? go1.19.3
No error occurs on v2.4.6, so I suspect it was introduced in this PR: #230
Metadata
Metadata
Assignees
Labels
No labels