Validate all fragments are used
This commit is contained in:
@ -124,7 +124,7 @@ spec = do
|
||||
let arguments = [Argument "message" (String "line1\nline2")]
|
||||
field = Field Nothing "field" arguments [] [] $ Location 0 0
|
||||
operation = DefinitionOperation
|
||||
$ SelectionSet (pure field)
|
||||
$ SelectionSet (pure $ FieldSelection field)
|
||||
$ Location 0 0
|
||||
in definition pretty operation `shouldBe` [r|{
|
||||
field(message: """
|
||||
|
@ -373,3 +373,23 @@ spec =
|
||||
, path = []
|
||||
}
|
||||
in validate queryString `shouldBe` Seq.singleton expected
|
||||
|
||||
it "rejects unused fragments" $
|
||||
let queryString = [r|
|
||||
fragment nameFragment on Dog { # unused
|
||||
name
|
||||
}
|
||||
|
||||
{
|
||||
dog {
|
||||
name
|
||||
}
|
||||
}
|
||||
|]
|
||||
expected = Error
|
||||
{ message =
|
||||
"Fragment \"nameFragment\" is never used."
|
||||
, locations = [AST.Location 2 15]
|
||||
, path = []
|
||||
}
|
||||
in validate queryString `shouldBe` Seq.singleton expected
|
||||
|
Reference in New Issue
Block a user