Heyo, fellas! 👋
I'm new to the tech, been trying to run locally
[{([:customer/id 123] {:pathom/context {:customer/first-name "Foo" :customer/last-name "Bar"}})
[:customer/full-name]}]
and it fails with
1. Unhandled java.lang.IllegalArgumentException
Key must be integer
APersistentVector.java: 294 clojure.lang.APersistentVector/invoke
REPL: 96 app.server-components.pathom/eval48368
REPL: 95 app.server-components.pathom/eval48368
Compiler.java: 7177 clojure.lang.Compiler/eval
Compiler.java: 7132 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
interruptible_eval.clj: 91 nrepl.middleware.interruptible-eval/evaluate/fn
main.clj: 437 clojure.main/repl/read-eval-print/fn
main.clj: 437 clojure.main/repl/read-eval-print
main.clj: 458 clojure.main/repl/fn
main.clj: 458 clojure.main/repl
main.clj: 368 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 155 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 190 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 189 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 830 java.lang.Thread/run
Bit more of context:
(defn build-parser [db-connection]
(let [real-parser (p/parallel-parser
{::p/mutate pc/mutate-async
::p/env {::p/reader [p/map-reader pc/parallel-reader
pc/open-ident-reader p/env-placeholder-reader]
::p/placeholder-prefixes #{">"}}
::p/plugins [(pc/connect-plugin {::pc/register all-resolvers})
(p/env-wrap-plugin (fn [env]
;; Here is where you can dynamically add things to the resolver/mutation
;; environment, like the server config, database connections, etc.
(assoc env
:db (d/db db-connection)
:conn db-connection
:config config)))
(preprocess-parser-plugin log-requests)
p/error-handler-plugin
p/request-cache-plugin
(p/post-process-parser-plugin p/elide-not-found)
p/trace-plugin]})
;; NOTE: Add -Dtrace to the server JVM to enable Fulcro Inspect query performance traces to the network tab.
;; Understand that this makes the network responses much larger and should not be used in production.
trace? (not (nil? (System/getProperty "trace")))]
(fn wrapped-parser [env tx]
(async/<!! (real-parser env (if trace?
(conj tx :com.wsscode.pathom/trace)
tx))))))
((build-parser (client/get-conn))
{} [{([:customer/id 123] {:pathom/context {:customer/first-name "Foo" :customer/last-name "Bar"}})
[:customer/full-name]}])
com.wsscode/pathom {:mvn/version "2.2.31"}
Any leads?
Sorry if it had been asked, googled something close in clojurians slack log, but the site appears down for me
The "Bit more of context" part isn't necessary. Clojure vectors can be called as functions. You can call vectors with indices, and get back elements at those indices. For example, ([:a :b] 0)
evaluates to :a
and ([:a :b] 1)
evaluates to :b
.
In your case, you're trying to call [:customer/id 123]
like a function, but with something that's not an int (like indices). So, you're getting the IllegalArgumentException
You can quote the list to get around this. For example, try ([:a :b] 100)
and '([:a :b] 100)
in your REPL.
you can get the cached version by clicking the little arrow next to the result and hitting "Cached"
> Clojure vectors can be called as functions being my third year in production I learn that only now haha 😅 thank ya
oh indeed, nice move