Fork me on GitHub
#pathom
<
2018-10-27
>
souenzzo14:10:52

Can I remove not-found entries from final result maps?

souenzzo14:10:44

I tried to use p/elide-not-found as a reader and failed. Now using in the right way. But i think that I can do the same faster with #specter

wilkerlucio19:10:22

@souenzzo yes, you should use the p/elide-not-found in combination with the p/post-process-plugin

wilkerlucio19:10:45

looks like this: (p/post-process-parser-plugin (p/elide-not-found))

wilkerlucio19:10:53

in the ::p/plugins list

currentoor21:10:56

So @wilkerlucio my parser looks like this, I added the ::pc/mutation-join-globals key

(def parser
  (p/parser
    {::p/mutate  server/server-mutate
     ::p/plugins [(p/env-wrap-plugin (fn [env]
                                       (assoc env ::pc/indexes @indexes)))
                  (p/env-plugin {::p/reader               [p/map-reader
                                                           pc/all-readers
                                                           (p/placeholder-reader ">")]
                                 ::p/placeholder-prefixes #{">"}
                                 ::pc/mutation-join-globals [::prim/tempids]
                                 ::pc/resolver-dispatch   resolver-fn})
                  p/request-cache-plugin
                  pp/profile-plugin
                  (preprocess-parser-plugin log-requests)
                  (preprocess-parser-plugin add-current-info)
                  (p/post-process-parser-plugin p/elide-not-found)]}))

currentoor21:10:12

and my mutation looks like this

(defmutation new-wash
  [{:keys [wash-id]}]
  (with [env] s.policy/existence)
  (action [{:keys [db conn current/firm current/user]}]
    (let [db-id (wash/create conn {:org-id  (:db/id firm)
                                               :user-id (:db/id user)})]
      {::prim/tempids {wash-id db-id}})))

currentoor21:10:41

but the tempid remapping is still not happening

wilkerlucio21:10:40

@currentoor I'm not using this in quite a time, so it's possible there is a bug, I'm currently updating the code in the docs, I can double check and get back to you if it's working properly there

currentoor21:10:57

oh ok, thanks

wilkerlucio22:10:02

@currentoor I just tried running hte book code, it seems to work there, at least in terms of data return, can you check on inspect if the tempids key is been returned from the network call?