Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type's line number always off by one if it includes a bang #231

Closed
zmay2030 opened this issue Jul 12, 2022 · 1 comment · Fixed by #236
Closed

Type's line number always off by one if it includes a bang #231

zmay2030 opened this issue Jul 12, 2022 · 1 comment · Fixed by #236

Comments

@zmay2030
Copy link
Contributor

package main

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/vektah/gqlparser/v2/ast"
	"github.com/vektah/gqlparser/v2/parser"
)


func TestTypePosition(t *testing.T) {
	t.Run("type line number with no bang", func(t *testing.T) {
		schema, parseErr := ParseSchema(&ast.Source{
			Input: `type query {
						me: User
					}
			`,
		})
		assert.Nil(t, parseErr)
		assert.Equal(t, 2, schema.Definitions.ForName("query").Fields.ForName("me").Type.Position.Line)
	})
	t.Run("type line number with bang", func(t *testing.T) {
		schema, parseErr := ParseSchema(&ast.Source{
			Input: `type query {
						me: User!
					}
			`,
		})
		assert.Nil(t, parseErr)
		assert.Equal(t, 2, schema.Definitions.ForName("query").Fields.ForName("me").Type.Position.Line)
	})
}

The second test fails and gives an actual of 3. Seems like it just happens when the type has a bang.

@StevenACoffman
Copy link
Collaborator

Huh! Weird! I would love a pull request to fix this.

zmay2030 pushed a commit to zmay2030/gqlparser that referenced this issue Sep 8, 2022
StevenACoffman pushed a commit that referenced this issue Sep 9, 2022
…line number (#236)

Co-authored-by: Ahmad Moudani <ahmad.moudani@crowdstrike.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants