Fork me on GitHub
#pathom
<
2020-03-10
>
souenzzo14:03:32

Hello I'm trying to use datomic-connect-plugin But my parser just returns the data inserted after it's creation (it kind of snapshot my DB at de creation of the parser)

com.wsscode/pathom-datomic {:git/url ""
                            :sha     "23e23ac8ae96dba5461cd020879d896c355f65d3"}
_
(let [parser-from-conn (fn [conn]
                         (p/parser {::p/env     {::p/placeholder-prefixes #{">"}
                                                 ::p/reader               [p/map-reader
                                                                           pc/reader2
                                                                           pc/open-ident-reader
                                                                           p/env-placeholder-reader]}
                                    ::p/mutate  pc/mutate
                                    ::p/plugins [(pc/connect-plugin {::pc/register pcd/registry})
                                                 (pcd/datomic-connect-plugin (assoc on-prem-config ::pcd/conn conn))
                                                 p/error-handler-plugin
                                                 p/trace-plugin]}))
      db-uri (doto (str "datomic:mem://" (UUID/randomUUID))
               d/create-database)
      tx-schema [{:db/ident       :user/id
                  :db/unique      :db.unique/identity
                  :db/valueType   :db.type/string
                  :db/cardinality :db.cardinality/one}
                 {:db/ident       :user/name
                  :db/valueType   :db.type/string
                  :db/cardinality :db.cardinality/one}]
      conn (d/connect db-uri)
      _ @(d/transact conn tx-schema)
      p1 (parser-from-conn conn)
      tx-data [{:user/id   "1"
                :user/name "one"}]
      {:keys [db-after]} @(d/transact conn tx-data)
      p2 (parser-from-conn conn)
      parser (juxt p1 p2)
      query [{[:user/id "1"] [:user/name]}]]
  {:without-db    (parser {::pcd/conn conn
                           ::p/entity {::pcd/conn conn}}
                          query)
   :with-db-after (parser {::pcd/conn conn
                           ::pcd/db   db-after
                           ::p/entity {::pcd/conn conn
                                       ::pcd/db   db-after}}
                          query)})
=>
{:without-db [{[:user/id "1"] {:user/name :com.wsscode.pathom.core/not-found}} {[:user/id "1"] {:user/name "one"}}],
 :with-db-after [{[:user/id "1"] {:user/name :com.wsscode.pathom.core/not-found}} {[:user/id "1"] {:user/name "one"}}]}

wilkerlucio13:03:49

yeah, the DB is kind static on that sense, I have not got to this point, but I think its an important one to tackle, can you open an issue on pathom-datomic to keep track of it?

👍 2