File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -336,7 +336,6 @@ func (p *parser) parseTypeReference() *Type {
336
336
}
337
337
338
338
if p .skip (lexer .Bang ) {
339
- typ .Position = p .peekPos ()
340
339
typ .NonNull = true
341
340
}
342
341
return & typ
Original file line number Diff line number Diff line change 1
1
package parser
2
2
3
3
import (
4
+ "github.com/stretchr/testify/assert"
4
5
"github.com/vektah/gqlparser/v2/gqlerror"
5
6
"testing"
6
7
@@ -18,7 +19,30 @@ func TestSchemaDocument(t *testing.T) {
18
19
}
19
20
}
20
21
return testrunner.Spec {
21
- AST : ast .Dump (doc ),
22
+ AST : ast .Dump (doc ),
22
23
}
23
24
})
24
25
}
26
+
27
+ func TestTypePosition (t * testing.T ) {
28
+ t .Run ("type line number with no bang" , func (t * testing.T ) {
29
+ schema , parseErr := ParseSchema (& ast.Source {
30
+ Input : `type query {
31
+ me: User
32
+ }
33
+ ` ,
34
+ })
35
+ assert .Nil (t , parseErr )
36
+ assert .Equal (t , 2 , schema .Definitions .ForName ("query" ).Fields .ForName ("me" ).Type .Position .Line )
37
+ })
38
+ t .Run ("type line number with bang" , func (t * testing.T ) {
39
+ schema , parseErr := ParseSchema (& ast.Source {
40
+ Input : `type query {
41
+ me: User!
42
+ }
43
+ ` ,
44
+ })
45
+ assert .Nil (t , parseErr )
46
+ assert .Equal (t , 2 , schema .Definitions .ForName ("query" ).Fields .ForName ("me" ).Type .Position .Line )
47
+ })
48
+ }
You can’t perform that action at this time.
0 commit comments