Skip to content

Commit

Permalink
test: implement DIsableSuggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
tomoikey committed Sep 23, 2024
1 parent c01da5c commit 14c9ed8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions validator/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,31 @@ func TestNoUnusedVariables(t *testing.T) {
require.Nil(t, validator.Validate(s, q))
})
}

func TestValidateOptionDisableSuggestion(t *testing.T) {
s := gqlparser.MustLoadSchema(&ast.Source{Name: "graph/schema.graphqls", Input: `
extend type User {
id: ID!
}
extend type Query {
user: User!
}
`, BuiltIn: false},
)

q, err := parser.ParseQuery(&ast.Source{Name: "ff", Input: `{
user {
idd
}
}`})

r := validator.Validate(s, q)
require.NoError(t, err)
require.Len(t, r, 1)
require.EqualError(t, r[0], `ff:3: Cannot query field "idd" on type "User". Did you mean "id"?`)

r = validator.Validate(s, q, validator.DisableSuggestion{})
require.Len(t, r, 1)
require.EqualError(t, r[0], `ff:3: Cannot query field "idd" on type "User".`)
}

0 comments on commit 14c9ed8

Please sign in to comment.