forked from wilkerlucio/pathom3-datomic
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reproduction of 'Pathom cannot find a path for the following elements…
…' issue
- Loading branch information
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
test/com/wsscode/pathom3/connect/datomic_devlocal_test.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"}}))))) |