WorksHub / leona

spec -> lacinia schema
Eclipse Public License 1.0
36 stars 17 forks source link

Leona doesn't extract enums from input specs which leads to compile failure #15

Closed acron0 closed 5 years ago

acron0 commented 5 years ago

For example

(s/def ::my-value int?)
(s/def ::my-object (s/keys :req-un [::my-value]))
(s/def ::my-query-enum #{"foo" "bar" "baz"})
(s/def ::query-args (s/keys :req-un [::my-query-enum]))

(-> (leona/create)
    (leona/attach-query ::query-args ::my-object some-handler)
    (leona/compile))

... will fail, because ::my-query-enum does not appear in the :enums map of the generated schema.

Error:

Argument `my_query_enum' of field `QueryRoot/my_object' references unknown type `my_query_enum'.
nathell commented 5 years ago

Until this is fixed, the workaround is to add ::query-args to Leona's specs manually before compiling the schema.

Like this:

(-> (leona/create)
    (leona/attach-query ::query-args ::my-object some-handler)
    (update :specs conj ::query-args) ; <- workaround
    (leona/compile))