We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies.

We use cookies and other tracking technologies to improve your browsing experience on our site, analyze site traffic, and understand where our audience is coming from. To find out more, please read our privacy policy.

By choosing 'I Accept', you consent to our use of cookies and other tracking technologies. Less

We use cookies and other tracking technologies... More

Login or register
to apply for this job!

Login or register to start contributing with an article!

Login or register
to see the full job description!

Login or register
to boost this post!

Show some love to the author of this blog by giving their post some rocket fuel 🚀.

Login or register to search for your ideal job!

Login or register to start working on this issue!

Engineers who find a new job through JavaScript Works average a 15% increase in salary 🚀

Support queries with no arguments

Issue closed
Pull requests: 1
Contributors: 1
Level: Intermediate
  • Clojure
  • $50
Issue closed
Pull requests: 1
Contributors: 1
Level: Intermediate
  • Clojure
  • $50

On GitHub

spec -> lacinia schema
More info >

Issue posted by: 
nathell's avatar

Daniel Janus

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) 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.
  • enhancement
  • help wanted

Use Open Source Issues to hire or get hired

On GitHub

spec -> lacinia schema
More info >

Issue posted by: 
nathell's avatar

Daniel Janus

Use Open Source Issues to hire or get hired

Support queries with no arguments
View on GitHub