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) or nil? 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 in Call to #'com.walmartlabs.lacinia.schema/compile did not conform to spec.
Did you try using (s/nilable map?)? That should have similar semantics to (s/nilable (s/keys)), as the latter does not make any assertion on keys not listed, i.e. it also refers to a map with arbitrary keys.
Currently, doing:
produces a schema that compiles successfully. However, trying to query it:
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, andnil
obviously doesn't validate against::no-args
.Some attempted workarounds that kaboom in all sorts of interesting ways:
::no-args
as(s/cat)
ornil?
makes the schema fail to compile with an AssertionError.::no-args
as(s/nilable (s/keys))
makes the schema fail to compile with an NPE.(leona/attach-query (s/nilable ::no-args) ::my-query my-query-resolver)
makes the schema fail to compile with an NPE.::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.