Fork me on GitHub
Spencer Apple05:10:21

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
  (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:

metal 1

@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)

Spencer Apple17:10:49

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]}))