This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-19
Channels
- # announcements (2)
- # beginners (12)
- # cider (12)
- # cljsrn (1)
- # clojure (56)
- # clojure-italy (1)
- # clojure-sweden (2)
- # clojure-uk (3)
- # clojured (6)
- # clojurescript (16)
- # cursive (1)
- # data-science (3)
- # datomic (8)
- # emacs (18)
- # figwheel-main (1)
- # graphql (5)
- # jobs (10)
- # luminus (4)
- # nrepl (27)
- # off-topic (5)
- # pathom (7)
- # shadow-cljs (66)
- # sql (40)
- # tools-deps (1)
- # vim (6)
Hey! Thanks for your work on Pathom! I am struggling with two things and if you have some time I would love some help. 1. what's the best way to pass a request env (like ring's) into pathom?
;; I call this api-parser via the fulcro websockets networking
(defn api-parser
([query] (pathom-parser {} query))
([env query]
;; should I just pass the env directly here?
(pathom-parser {:user (:user (:request env))} query)))
2. I have the following resolvers and am making a query which to me makes sense, but it's not returning my room.
(pc/defresolver room-resolver [env input]
{::pc/input #{:room/id :user/id}
::pc/output [:room/id
:room/status]}
(util/log "calling room-resolver")
(get-in @state/room-table [(:user/id input) (:room/id input)]))
(pc/defresolver user-resolver [env input]
{::pc/output [:user/id]}
{:user/id :base-state})
Then I can run the query which finds the user-resolver but not the room resolver
(api-parser [:user/id {[:room/id :] [:room/id :room/status]}])
;; => {:user/id :base-state, [:room/id :] :com.wsscode.pathom.core/not-found}
My understanding is that pathom should realize that the room resolver can be fulfilled since there is a :user/id and :room/id. Any ideas?@cjsauer yes, you can query for the indexes, that's how the auto-complete for queries currently works, it downloads the indexes and show it, there is also the index explorer: https://wilkerlucio.github.io/pathom/v2/pathom/2.2.0/connect/exploration.html
@splayemu to send stuff to env, use the first argument of the parser, as you used, I suggest you pass the whole request, like: (pathom-parser {::request request} [...])
also, remember to use qualified keywords to avoid collisions
about the resolvers, they look strange as is
::pc/input #{:room/id :user/id}
is not a good way, you are making a dependency hard to reach, if you can use a single id would be great (and have normalized structures to request from)
Thanks, yeah as you suggested, it does make sense to use a single id. I turned it into a single id and built a resolver to combine the user-id and room-id:
(pc/defresolver user-room-resolver [env {:keys [room/id]}]
{::pc/input #{:room/id}
::pc/output [:user-room/id]}
(let [user-id (-> env :user :user/id)]
{:user-room/id [user-id id]}))