Fork me on GitHub
#fulcro
<
2022-05-10
>
Carlo23:05:24

@holyjak I was running again through the Fulcro exercises. It seems to me that https://github.com/fulcro-community/fulcro-exercises/blob/main/src/holyjak/solutions.cljs#L406-L411= should be:

(defresolver my-very-awesome-teams [_ _] ; a global resolver
      {::pc/input  #{}
       ::pc/output [{:teams [:team/id :team/name :team/players]}]}
      {:teams [#:team{:id :hikers}]})
since I already defined the resolver for teams. Is this correct?

wilkerlucio02:05:35

looking at it, I think ideally that resolver should be:

(defresolver my-very-awesome-teams [_ _] ; a global resolver
      {::pc/input  #{}
       ::pc/output [{:teams [:team/id :team/name {:team/players [:player/id]}]}]}
      {:teams [#:team{:name "Hikers" :id :hikers
                      :players [#:player{:id 1}
                                #:player{:id 2}]}]})

👍 1
🙌 1
wilkerlucio02:05:01

@UA7E6DU04 I dont have the full context here, but the output description should match the max possibility of things it can provide, and no more, in the original code it was missing the nested details on :team/players, in your case the resolver describes having :team/name and :team/players inside the response, but if that's only that static map, those keys will never be present in the output, so they should be removed from the ::pc/output

🙌 1
Jakub Holý (HolyJak)10:05:27

@UA7E6DU04 you are right, you could do that. I have added a comment about it. I was more thinking about the real use case where you would have

(defresolver my-very-awesome-teams ... (database/get-all-teams))
(defresolver team [_ {id :team/id}] ... (database/get-team+by-id id)) 
where you would not necessarily reuse them.

🙌 1