In Lacinia, I have a query with an argument of type List without Non-Null type modifier. If I provide argument value null using a query variable I'll get nil from the resolver's argument map as I would have expected. However, if I provide null directly as a query argument value it seems to be coerced to an empty list. For example:
(require '[com.walmartlabs.lacinia.schema :as schema])
(require '[com.walmartlabs.lacinia :as lacinia])
(let [s (schema/compile {:queries {:testQuery {:type '(list Int)
:args {:testArg {:type '(list Int)}}
:resolve (fn [ctx args v]
(println "testArg =" (:testArg args))
(:testArg args))}}})
with-variable "query ($testArg:[Int]) {
testQuery(testArg: $testArg)
}"
without-variable "query {
testQuery(testArg: null)
}"
]
(println "with-variable =" (lacinia/execute s with-variable {:testArg nil} nil))
(println "without-variable =" (lacinia/execute s without-variable nil nil)))
Which prints:
testArg = nil
with-variable = {:data #ordered/map ([:testQuery nil])}
testArg = []
without-variable = {:data #ordered/map ([:testQuery []])}
I'm a bit confused, I would have expected nil from the resolver's argument map in the latter case also. There seems to be tests for both behaviors e.g. former https://github.com/walmartlabs/lacinia/blob/8842b48569c8139c593ecc0136a9d80f353dd975/test/com/walmartlabs/lacinia/custom_scalars_test.clj#L369 and latter https://github.com/walmartlabs/lacinia/blob/8842b48569c8139c593ecc0136a9d80f353dd975/test/com/walmartlabs/lacinia_test.clj#L622.