Skip to content

Commit

Permalink
reproduction of 'Pathom cannot find a path for the following elements…
Browse files Browse the repository at this point in the history
…' issue
  • Loading branch information
secos committed May 9, 2022
1 parent ded08b5 commit 534d9ef
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 3 deletions.
5 changes: 4 additions & 1 deletion bb.edn
Expand Up @@ -26,7 +26,10 @@
tasks/setup-git-hooks

test
(shell "clojure" "-A:test:test-deps")
(shell "clojure" "-M:test")

test-local
(shell "clojure" "-M:test-local")

test-cljs
(shell "shadow-cljs" "watch" "test" "-A:test-deps:test-cljs")
Expand Down
16 changes: 14 additions & 2 deletions deps.edn
@@ -1,4 +1,5 @@
{:paths
{:mvn/repos {"datomic-cloud" {:url "s3://datomic-releases-1fc2183a/maven/releases"}}
:paths
["src/main"]

:deps
Expand All @@ -19,9 +20,20 @@

:test
{:extra-paths ["test"]
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git" :sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}}
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git" :sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}
com.datomic/client-cloud {:mvn/version "0.8.96"}
com.datomic/dev-local {:local/root "./dev-local-1.0.242.jar"}} ;; jar not included, see https://docs.datomic.com/cloud/dev-local.html for installation instructions}
:main-opts ["-m" "cognitect.test-runner"]}

:test-local
{:extra-paths ["test"]
:extra-deps {com.cognitect/test-runner {:git/url "https://github.com/cognitect-labs/test-runner.git" :sha "209b64504cb3bd3b99ecfec7937b358a879f55c1"}
com.datomic/client-cloud {:mvn/version "0.8.96"}
com.datomic/dev-local {:local/root "./dev-local-1.0.242.jar"}} ;; jar not included, see https://docs.datomic.com/cloud/dev-local.html for installation instructions
:main-opts ["-m" "cognitect.test-runner"]}

:test-cljs
{:extra-paths ["test"]
:extra-deps {thheller/shadow-cljs {:mvn/version "2.11.9"}}}}}


49 changes: 49 additions & 0 deletions test/com/wsscode/pathom3/connect/datomic_devlocal_test.clj
@@ -0,0 +1,49 @@
(ns com.wsscode.pathom3.connect.datomic-devlocal-test
(:require
[clojure.test :as t :refer :all]
[com.wsscode.pathom3.connect.built-in.plugins :as pbip]
[com.wsscode.pathom3.connect.datomic :as pcd]
[com.wsscode.pathom3.connect.datomic.client :refer [client-config]]
[com.wsscode.pathom3.connect.indexes :as pci]
[com.wsscode.pathom3.connect.operation :as pco]
[com.wsscode.pathom3.interface.eql :as p.eql]
[com.wsscode.pathom3.plugin :as p.plugin]
[datomic.client.api :as d]))

;;
;; Setup
;; 1) Install Datomic dev-local (https://docs.datomic.com/cloud/dev-local.html#getting-started)
;; 2) Install sample data (https://docs.datomic.com/cloud/dev-local.html#samples)
;;

(def client (d/client {:server-type :dev-local
:system "datomic-samples"}))
(def datomic-config {:db-name "mbrainz-subset"})
(d/create-database client datomic-config)
(def conn (d/connect client datomic-config))
(def db (d/db conn))

(def db-config
(assoc client-config
::pco/op-name `mbrainz))

(def registry
[])

(def env-admin
(-> (pci/register
[registry])
(pcd/connect-datomic
(assoc db-config
::pcd/conn conn
::pcd/admin-mode? true
::pcd/ident-attributes #{:artist/type}))
(p.plugin/register (pbip/attribute-errors-plugin))))

(def request-admin (p.eql/boundary-interface env-admin))

(deftest datomic-admin-mode-test
(testing "reading from :db/id"
(let [janis-eid (ffirst (d/q '[:find ?id :where [?id :artist/name "Janis Joplin"]] db))]
(is (= (request-admin [{[:db/id janis-eid] [:artist/name]}])
{[:db/id janis-eid] {:artist/name "Janis Joplin"}})))))

0 comments on commit 534d9ef

Please sign in to comment.