server: add test case for null value forwarding in Remote Schemas

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9800
Co-authored-by: Auke Booij <164426+abooij@users.noreply.github.com>
GitOrigin-RevId: 2be2b2f794aa3236a1204ac3ef24283dabbcf429
This commit is contained in:
pranshi06 2023-07-07 18:39:46 +05:30 committed by hasura-bot
parent 2bc882ebc9
commit 0151e25e8b

View File

@ -183,6 +183,7 @@ spec = do
testNoVarExpansionIfNoPreset
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalField
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullField
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullFieldForObjectField
testPartialVarExpansionIfPreset
testVariableSubstitutionCollision
@ -294,7 +295,7 @@ query($a: A) {
)
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullField :: Spec
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullField = it "send null value in the input variable for nullable field" $ do
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullField = it "send null value in the input variable for nullable scalar field" $ do
field <-
run
-- schema
@ -328,6 +329,53 @@ query ($a: Int) {
(J.Null)
)
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullFieldForObjectField :: Spec
testNoVarExpansionIfNoPresetUnlessTopLevelOptionalFieldSendNullFieldForObjectField = it "send null value in the input variable for nullable object field " $ do
field <-
run
-- schema
[raw|
scalar Int
input A {
b: B
}
input B {
c: C
}
input C {
i: Int
}
type Query {
test(a: A): Int
}
|]
-- query
[raw|
query($a: A) {
test(a: $a)
}
|]
-- variables
[raw|
{
"a": null
}
|]
let arg = head $ HashMap.toList $ _fArguments field
arg
`shouldBe` ( _a,
-- fieldOptional has peeled the variable; all we see is a JSON blob, and in doubt
-- we repackage it as a newly minted JSON variable
G.VVariable
$ RemoteJSONValue
(G.TypeNamed (G.Nullability True) _A)
(J.Null)
)
testPartialVarExpansionIfPreset :: Spec
testPartialVarExpansionIfPreset = it "presets cause partial var expansion" $ do
field <-