Fork me on GitHub

consider ::pco/output of the department->manager , could you explain what are the possible differences/implications of them. all three works

(pco/defresolver department-id->department [{:keys [db-hr]} {:keys [department/id]}]
  {::pco/input [:department/id]
   ::pco/output [:department/id
      ["select department_id, department_name, manager_id, location_id from hr.departments where department_id=?" id]
      {:builder-fn rs/as-unqualified-lower-maps})))

(pco/defresolver department->location [{:keys [department/location_id]}]
  {::pco/output [:department/location]}
  {:department/location {:location/id location_id}})

(pco/defresolver department->manager [{:keys [department/manager_id]}]
  {::pco/output [{:department/manager [:employee/id]}]}
  {:department/manager {:employee/id manager_id}})

; (pco/defresolver department->manager [{:keys [department/manager_id]}]
;   {::pco/output [:department/manager]}
;   {:department/manager {:employee/id manager_id}})

; (pco/defresolver department->manager [{:keys [department/manager_id]}]
;   {::pco/output [{:department/manager [:foo]}]}
;   {:department/manager {:employee/id manager_id}})

Björn Ebbinghaus15:03:42

So: You resolve :employee/id coincidental through :department/manager meaning, that if you have some other resolver that provides :department/manager but not :employee/id it can be possible that pathom won't be able to resolve :employee/id Imagine you add another resolver:

(pco/defresolver something->manager [{:keys [something]}]
  {:department/manager something})
And you run the query:
[{:department/manager [:employee/id]}]
How should Pathom decide which resolver to use? Maybe it chooses something->manager to resolve :department/manager and has no clue how to get to :employee/id . Additionally, you lose things like autocomplete and documentation in Pathom Viz. From`defresolver` > IMPORTANT > Both input and output can express flat or nested queries, you should always strive to be as precise with these descriptions as you can (matching the shapes of your inputs and outputs), Pathom leverages this information in many ways during transaction processing, and as more accurate you get, the more Pathom can do with it. You can return more data than you defined, but you should only do that "as a bonus" and you shouldn't rely on that.

👌 1
Björn Ebbinghaus16:03:08

And: You can elide the ::pco/output config in this example, as you directly return just maps.