Does anyone understand the code in https://lacinia.readthedocs.io/en/latest/tutorial/designer-data.html:
(defn resolve-board-game-designers
[designers-map context args board-game]
(->> board-game
:designers
(map designers-map)))
designers-map
:
{"200" {:id "200", :name "Kris Burm", :url "<http://www.gipf.com/project_gipf/burm/burm.html>"}, "201" {:id "201", :name "Antoine Bauza", :url "<http://www.antoinebauza.fr/>"}, "202" {:id "202", :name "Bruno Cathala", :url "<http://www.brunocathala.com/>"}, "203" {:id "203", :name "Scott Almes"}, "204" {:id "204", :name "Donald X. Vaccarino"}}
(:designers board-game)
:
#{"201" "202"}
Aha
So (map designers-map #{"201" "202"})
;; =>
({:id "201", :name "Antoine Bauza", :url "<http://www.antoinebauza.fr/>"} {:id "202", :name "Bruno Cathala", :url "<http://www.brunocathala.com/>"})
user> (map {:a "a" :b "b" :c "c"} #{:a :b})
("b" "a")
Mapping a map over a set leads to the keys of that set extracted out of the map, which is logical
Now I see
Okay π
Maps can acts like functions ... but perhaps the code in the tutorial is a bit too concise.
Yes I see now it uses (my-map <:key>)
, but I find it more usual to call it other way around, and to me it was not clear that (:designers board-game)
was a set of numberstrings.
So I thought it was doing some set/map magic I did not know yet
But I am very happy with the example
Really really nice tutorial. Thanks!
So today I tried to implement the node query as specified by the relay specification, I was wondering whether other people are doing the same in Lacinia, and what the best way is to combat code duplication between βnormalβ query fields and retrieving entities using the node query
I basically kinda created a big switch case for schema types, go to the database to retrieve my entity and convert it to the expected value but the last step is duplicated amongst all different ways you can retrieve the same type of entities