Test nullability on value completion
This commit is contained in:
parent
7b00e8a0ab
commit
60d1167839
@ -106,6 +106,7 @@ philosopherType = Out.ObjectType "Philosopher" Nothing []
|
|||||||
, ("interest", ValueResolver interestField interestResolver)
|
, ("interest", ValueResolver interestField interestResolver)
|
||||||
, ("majorWork", ValueResolver majorWorkField majorWorkResolver)
|
, ("majorWork", ValueResolver majorWorkField majorWorkResolver)
|
||||||
, ("century", ValueResolver centuryField centuryResolver)
|
, ("century", ValueResolver centuryField centuryResolver)
|
||||||
|
, ("firstLanguage", ValueResolver firstLanguageField firstLanguageResolver)
|
||||||
]
|
]
|
||||||
firstNameField =
|
firstNameField =
|
||||||
Out.Field Nothing (Out.NonNullScalarType string) HashMap.empty
|
Out.Field Nothing (Out.NonNullScalarType string) HashMap.empty
|
||||||
@ -131,6 +132,9 @@ philosopherType = Out.ObjectType "Philosopher" Nothing []
|
|||||||
centuryField =
|
centuryField =
|
||||||
Out.Field Nothing (Out.NonNullScalarType int) HashMap.empty
|
Out.Field Nothing (Out.NonNullScalarType int) HashMap.empty
|
||||||
centuryResolver = pure $ Float 18.5
|
centuryResolver = pure $ Float 18.5
|
||||||
|
firstLanguageField
|
||||||
|
= Out.Field Nothing (Out.NonNullScalarType string) HashMap.empty
|
||||||
|
firstLanguageResolver = pure Null
|
||||||
|
|
||||||
workType :: Out.InterfaceType (Either SomeException)
|
workType :: Out.InterfaceType (Either SomeException)
|
||||||
workType = Out.InterfaceType "Work" Nothing []
|
workType = Out.InterfaceType "Work" Nothing []
|
||||||
@ -333,6 +337,20 @@ spec =
|
|||||||
$ parse document "" "{ count }"
|
$ parse document "" "{ count }"
|
||||||
in actual `shouldBe` expected
|
in actual `shouldBe` expected
|
||||||
|
|
||||||
|
it "detects nullability errors" $
|
||||||
|
let data'' = Aeson.object
|
||||||
|
[ "philosopher" .= Aeson.Null
|
||||||
|
]
|
||||||
|
executionErrors = pure $ Error
|
||||||
|
{ message = "Value completion error. Expected type !String, found: null."
|
||||||
|
, locations = [Location 1 26]
|
||||||
|
, path = [Segment "philosopher", Segment "firstLanguage"]
|
||||||
|
}
|
||||||
|
expected = Response data'' executionErrors
|
||||||
|
Right (Right actual) = either (pure . parseError) execute'
|
||||||
|
$ parse document "" "{ philosopher(id: \"1\") { firstLanguage } }"
|
||||||
|
in actual `shouldBe` expected
|
||||||
|
|
||||||
context "Subscription" $
|
context "Subscription" $
|
||||||
it "subscribes" $
|
it "subscribes" $
|
||||||
let data'' = Aeson.object
|
let data'' = Aeson.object
|
||||||
|
Loading…
Reference in New Issue
Block a user