Fork me on GitHub
#pathom
<
2019-06-14
>
wilkerlucio03:06:15

[com.wsscode.pathom "2.2.15" is out! Changes: * Fix pc/data->shape breaking when data has complex keys * Fix alias on p/join-seq-parallel optimized runs (https://github.com/wilkerlucio/pathom/issues/89)

🎉 8
wilkerlucio03:06:13

also updated docs for placeholders: https://wilkerlucio.github.io/pathom/#_placeholders thanks to @tony.kay for pointing the missing full examples

uwo13:06:55

Any obvious places to look if the index-explorer isn't working? When I try to connect I get an error like this java.lang.RuntimeException: java.lang.Exception: Not supported: class <one of my resolvers>

wilkerlucio14:06:25

@uwo the issue that happens here is because its likely trying to encode things in transit that it doesn't know about, my suggestion is to use transit default handlers so it encode it anyway (even if it can't properly read on the other side, doesn't matter, those keys are not going to be read anyway)

🙏 4
wilkerlucio14:06:03

I really need to add this to the docs there

wilkerlucio14:06:36

specially because there is a bug in transit where the default write handlers don't work, so there is some code needed to make that work

wilkerlucio14:06:38

(deftype DefaultHandler []
  WriteHandler
  (tag [this v] "unknown")
  (rep [this v] (pr-str v)))

(defn writer
  "Creates a writer over the provided destination `out` using
   the specified format, one of: :msgpack, :json or :json-verbose.
   An optional opts map may be passed. Supported options are:
   :handlers - a map of types to WriteHandler instances, they are merged
   with the default-handlers and then with the default handlers
   provided by transit-java.
   :transform - a function of one argument that will transform values before
   they are written."
  ([out type] (writer out type {}))
  ([^OutputStream out type {:keys [handlers transform default-handler]}]
   (if (#{:json :json-verbose :msgpack} type)
     (let [handler-map (merge transit/default-write-handlers handlers)]
       (transit/->Writer
         (TransitFactory/writer (#'transit/transit-format type) out handler-map default-handler
           (when transform
             (reify Function
               (apply [_ x]
                 (transform x)))))))
     (throw (ex-info "Type must be :json, :json-verbose or :msgpack" {:type type})))))

🙏 4
wilkerlucio14:06:49

then you can write with

wilkerlucio14:06:51

(defn write-transit [x]
  (let [baos (ByteArrayOutputStream.)
        w    (writer baos :json {:handlers transit-write-handlers
                                 :default-handler (DefaultHandler.)})
        _    (transit/write w x)
        ret  (.toString baos)]
    (.reset baos)
    ret))

🙏 4
wilkerlucio14:06:39

ok people, new section in the docs, how to fix transit encoding issues: https://wilkerlucio.github.io/pathom/#_fixing_transit_encoding_issues

🙏 12
uwo16:06:10

Thank you!!

uwo20:06:02

Has anyone here attempted to integrate vim omni-completion, ctrl-x-o, with pathom-index enabled autocompletion?

wilkerlucio20:06:49

@uwo not that I know, but if you have a running repl with pathom and the index, and you can communicate with that, the impl can be quite easy

wilkerlucio20:06:27

ctx is a vector with a path, examples: [:customer/id], [:my-app/all-users :user/groups]

wilkerlucio20:06:04

cache is optional, but can do great on improving performance, just send an atom with a map (and hold this atom, keep sending the same one)