Add a test for the wrong variable location

inside an input object for the role checking for unused and undefined
variables.
This commit is contained in:
Eugen Wissner 2023-12-28 09:45:39 +01:00
parent 59aa010f0b
commit b1b6bfcdb9
Signed by: belka
GPG Key ID: A27FDC1E8EE902C0
2 changed files with 17 additions and 2 deletions

View File

@ -11,6 +11,7 @@ and this project adheres to
- `gql` removes not only leading `\n` but also `\r`.
- Fix non nullable type string representation in executor error messages.
- Fix input objects not being coerced to lists.
- Fix used variables are not found in the properties of input objects.
## [1.2.0.1] - 2023-04-25
### Fixed

View File

@ -538,7 +538,7 @@ spec =
}
in validate queryString `shouldContain` [expected]
context "noUndefinedVariablesRule" $
context "noUndefinedVariablesRule" $ do
it "rejects undefined variables" $
let queryString = [gql|
query variableIsNotDefinedUsedInSingleFragment {
@ -560,6 +560,20 @@ spec =
}
in validate queryString `shouldBe` [expected]
xit "gets location of the variable inside an input object" $
let queryString = [gql|
query {
findDog (complex: { name: $name }) {
name
}
}
|]
expected = Error
{ message = "Variable \"$name\" is not defined."
, locations = [AST.Location 2 29]
}
in validate queryString `shouldBe` [expected]
context "noUnusedVariablesRule" $ do
it "rejects unused variables" $
let queryString = [gql|
@ -577,7 +591,7 @@ spec =
}
in validate queryString `shouldBe` [expected]
xit "detects variables in properties of input objects" $
it "detects variables in properties of input objects" $
let queryString = [gql|
query withVar ($name: String!) {
findDog (complex: { name: $name }) {