Fork me on GitHub
#pathom
<
2020-03-26
>
wilkerlucio23:03:56

it seems in your query side the :latest-invoice is missing the namespace, in the ::pc/output it is :organization/latest-invoice

4
Jakub Holý (HolyJak)09:03:54

OMG, thanks a lot! I would need some kind of "idiot mode" that prints warnings when i ask for a key that Pathom does not know about (and has another "similar" one)

wilkerlucio12:03:09

actually, that can be quite easy to do as an extra reader, try this setup and let me know what you think:

👀 4
wilkerlucio12:03:22

(defn validate-connect-key-reader [env]
  (let [k         (-> env :ast :key)
        index-oir (-> env ::pc/indexes ::pc/index-oir)]
    (when (and (not (p/ident? k))
               (not (p/placeholder-key? env k))
               (not (contains? index-oir k)))
      (println (str "WARN: trying to read key " k " which is not available in the index.")))

    ::p/continue))

(def parser
  (p/parser
    {::p/env     {::p/reader               [p/map-reader
                                            pc/reader3
                                            validate-connect-key-reader
                                            pc/open-ident-reader
                                            p/env-placeholder-reader]
                  ::p/placeholder-prefixes #{">"}}
     ::p/mutate  pc/mutate
     ::p/plugins [(pc/connect-plugin {::pc/indexes  indexes
                                      ::pc/register registry})
                  p/error-handler-plugin
                  p/trace-plugin]}))

wilkerlucio12:03:22

(defn validate-connect-key-reader [env]
  (let [k         (-> env :ast :key)
        index-oir (-> env ::pc/indexes ::pc/index-oir)]
    (when (and (not (p/ident? k))
               (not (p/placeholder-key? env k))
               (not (contains? index-oir k)))
      (println (str "WARN: trying to read key " k " which is not available in the index.")))

    ::p/continue))

(def parser
  (p/parser
    {::p/env     {::p/reader               [p/map-reader
                                            pc/reader3
                                            validate-connect-key-reader
                                            pc/open-ident-reader
                                            p/env-placeholder-reader]
                  ::p/placeholder-prefixes #{">"}}
     ::p/mutate  pc/mutate
     ::p/plugins [(pc/connect-plugin {::pc/indexes  indexes
                                      ::pc/register registry})
                  p/error-handler-plugin
                  p/trace-plugin]}))