Description
Currently, doing:
(s/def ::no-args (s/keys))
(s/def ::result string?)
(s/def ::my-query (s/keys :req-un [::result]))
(defn my-query-resolver [ctx args value]
{:result "hello"})
(def schema
(-> (leona/create)
(leona/attach-query ::no-args ::my-query my-query-resolver)
(leona/compile)))
produces a schema that compiles successfully. However, trying to query it:
(leona/execute schema "{ my_query { result } }")
bombs out with a spec failure: The query input didn't conform to the internal spec: ::no-args
. This is because Lacinia passes nil arguments to niladic query resolvers, and nil
obviously doesn't validate against ::no-args
.
Some attempted workarounds that kaboom in all sorts of interesting ways:
- Defining
::no-args
as(s/cat)
ornil?
makes the schema fail to compile with an AssertionError. - Defining
::no-args
as(s/nilable (s/keys))
makes the schema fail to compile with an NPE. - Attaching query as
(leona/attach-query (s/nilable ::no-args) ::my-query my-query-resolver)
makes the schema fail to compile with an NPE. - Defining
::no-args
on a two-step basis, as in:(s/def ::no-args-internal (s/keys)) (s/def ::no-args (s/nilable ::no-args-internal))
, makes Leona miscompile the schema, resulting inCall to #'com.walmartlabs.lacinia.schema/compile did not conform to spec.