Fork me on GitHub
#pathom
<
2021-05-13
>
p4ulcristian22:05:46

Hello everybody! I am using Pathom for a while now, it is fascinating, simplified my backend and frontend also. Now I try to do a file uploading example, but got myself in trouble.

(defmutation upload-files
  [env data]
  {::pco/op-name 'files/upload-files}
  (let [{:keys [directory-id files]} data]
    (println "Directory: " directory-id)
    "return"))

(p.eql/process
  env
  [`(files/upload-files {:directory-id directory-id})])
In the mutation the directory-id stays a symbol. I tried to (eval directory-id), but it didn't work. Also tried to expand my env with :
(def env
  (-> (pci/register registry)
      (p.plugin/register pbip/mutation-resolve-params)))
What should I do to make my params evaluate? I destructure them from the request.

souenzzo22:05:56

@paul931224 not a pathom issue, but an clojure-unquote issue. But file uploads may be a bit annoying to handle You are using fulcro? pedestal?

(p.eql/process
  env
  [`(files/upload-files ~{:directory-id directory-id})])

👍 3
p4ulcristian22:05:44

Thank you so much @souenzzo, I never had to use quote and eval in 6 years of clojure programming. Seems so easy now and trivial. We don't use nothing fancy like that, I get my files from multipart-params using ring . I made a route only for uploading the files, but wanted to do it with mutation . I have the files and everything, that was the last missing piece.

👍 3