Fork me on GitHub
#pathom
<
2019-10-30
>
Brian20:10:42

So I have this mutation:

(pc/defmutation add-artifact [env artifact]
  {::pc/sym `r9b.threat-intelligence.artifact/add-artifact
   ::pc/params [::note ::hash/sha-256]
   ::pc/output [:artifact/note]}
  ...)
How can I access the params? I've noticed that there can be any keys inside artifact and I want to remove all those that are not in the ::pc/params so that I can then reduce over artifact to do something meaningful. Is that possible?

wilkerlucio23:10:54

@brian.rogers hello, one way to do it is writing a ::pc/transform, using that you can wrap the mutation fn and do anything you want (like stripping params), a example:

wilkerlucio23:10:55

(defn filter-declared-params-transform
  [{::pc/keys [mutate params] :as mutation}]
  (cond-> mutation
    (and mutate params)
    (assoc
      ::pc/mutate
      (fn [env p]
        (mutate env (select-keys p params))))))

(pc/defmutation add-artifact [env artifact]
  {::pc/sym       `r9b.threat-intelligence.artifact/add-artifact
   ::pc/params    [::note ::hash/sha-256]
   ::pc/output    [:artifact/note]
   ::pc/transform filter-declared-params-transform}
  ...)

wilkerlucio23:10:03

then, if you wanna use it a lot, you can create your own defmutation that always adds it, or, considering that mutations are just maps, you can do some pre-processing on them before adding to the index (or maybe change the index after its ready, the mutation code fn also lives there)

eoliphant23:10:52

HEy I’m getting a “Seems like the index is not available.” in the inspector, I have the recommended index resolver in my parser config. any suggestions on a query to say run manually in the repl to diagnose the problem?