This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-01
Channels
- # beginners (133)
- # boot (59)
- # cider (5)
- # cljs-dev (30)
- # cljsrn (23)
- # clojure (212)
- # clojure-austin (3)
- # clojure-brasil (1)
- # clojure-chicago (5)
- # clojure-italy (10)
- # clojure-russia (5)
- # clojure-serbia (1)
- # clojure-spec (34)
- # clojure-turkiye (2)
- # clojure-uk (132)
- # clojurescript (163)
- # clojutre (1)
- # cursive (5)
- # datomic (58)
- # emacs (42)
- # events (1)
- # graphql (26)
- # hoplon (16)
- # jobs (1)
- # lumo (27)
- # numerical-computing (3)
- # off-topic (127)
- # om (9)
- # onyx (24)
- # re-frame (20)
- # reagent (20)
- # ring-swagger (14)
- # sql (19)
- # unrepl (28)
- # untangled (3)
- # vim (8)
- # yada (17)
I'm using lacinia, and running into problems with a simple example:
(schema/compile {:queries {
:hello {:type String
:resolve "hello"}}})
and i'm getting ExceptionInfo Could not process type. clojure.core/ex-info (core.clj:4617)
:resolve has to be a function; this will attempt to invoke ("hello" context args nil)
.
Chances are it's complaining about type QueryRoot and field hello, and there's an error because "hello" is not a function.
graphql-demo.server> (schema/compile {:queries {
:hello {:type String
:resolve (constantly "world")}}})
ExceptionInfo Could not process type. clojure.core/ex-info (core.clj:4617)
clojure.lang.ExceptionInfo: Could not process type.
clojure.lang.ExceptionInfo: Could not identify type of field.
clojure.core/eval core.clj: 3105
...
user/eval48926 REPL Input
com.walmartlabs.lacinia.schema/compile schema.clj: 812
com.walmartlabs.lacinia.schema/compile schema.clj: 818
com.walmartlabs.lacinia.schema/construct-compiled-schema schema.clj: 765
com.walmartlabs.lacinia.internal-utils/map-vals internal_utils.clj: 39
clojure.core/reduce-kv core.clj: 6573
clojure.core.protocols/fn/G protocols.clj: 174
clojure.core/fn core.clj: 6547
clojure.core/reduce core.clj: 6545
clojure.core.protocols/fn/G protocols.clj: 13
clojure.core.protocols/fn protocols.clj: 75
clojure.core.protocols/iter-reduce protocols.clj: 49
clojure.core/fn/fn core.clj: 6557
com.walmartlabs.lacinia.internal-utils/map-vals/fn internal_utils.clj: 40
com.walmartlabs.lacinia.schema/construct-compiled-schema/fn schema.clj: 765
...
com.walmartlabs.lacinia.schema/eval19878/fn schema.clj: 609
com.walmartlabs.lacinia.schema/compile-fields schema.clj: 529
clojure.core/update core.clj: 5960
com.walmartlabs.lacinia.schema/compile-fields/fn schema.clj: 529
com.walmartlabs.lacinia.internal-utils/map-kvs internal_utils.clj: 51
clojure.core/reduce-kv core.clj: 6573
clojure.core.protocols/fn/G protocols.clj: 174
clojure.core/fn core.clj: 6547
clojure.core/reduce core.clj: 6545
clojure.core.protocols/fn/G protocols.clj: 13
clojure.core.protocols/fn protocols.clj: 75
clojure.core.protocols/iter-reduce protocols.clj: 49
clojure.core/fn/fn core.clj: 6557
com.walmartlabs.lacinia.internal-utils/map-kvs/fn internal_utils.clj: 52
com.walmartlabs.lacinia.schema/compile-fields/fn/fn schema.clj: 530
com.walmartlabs.lacinia.schema/compile-field schema.clj: 335
com.walmartlabs.lacinia.schema/rewrite-type schema.clj: 317
clojure.core/update core.clj: 5960
com.walmartlabs.lacinia.schema/expand-type schema.clj: 291
clojure.core/ex-info core.clj: 4617
clojure.lang.ExceptionInfo: Could not process type.
type: java.lang.String
clojure.lang.ExceptionInfo: Could not identify type of field.
field: {:type java.lang.String,
:resolve
#object[clojure.core$constantly$fn__4614 0x19890edf "clojure.core$constantly$fn__4614@19890edf"]}
Ah, there's the problem. You need to quote 'String when doing this from REPL. That way String is a symbol, not a class. Easy to miss. Always best to put as much of your schema into EDN as possible, so that things don't get eval'ed.
I'm trying to come up with a very minimal example to add to the lacinia-pedestal docs. do you think it would be confusing to people coming to the library if it had the quoted 'String
in the example, but best practice is to store the schema in an .edn file?
Best practice is absolutely to store the schema as an EDN file. Schema at the REPL should be considered the exception, not the rule. Use the attach-resolvers
utility function.
I'm trying to improve the documentation in the lacinia and lacinia-pedestal project, as I found it quite difficult to get to a working project by following them
especially as someone who is new to lacinia and pedestal (and clojure!), barebones examples help a lot
We've put a lot (a lot) of effort into the Lacinia docs, but it's a never-ending struggle to keep them readible, upto date, and accurate.