graphql

erwinrooijakkers 2019-02-21T13:02:25.000700Z

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

erwinrooijakkers 2019-02-21T13:05:02.001400Z

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"}

erwinrooijakkers 2019-02-21T13:05:06.001700Z

Aha

erwinrooijakkers 2019-02-21T13:05:36.002300Z

So (map designers-map #{"201" "202"})

erwinrooijakkers 2019-02-21T13:07:46.002600Z

;; =&gt;
({:id "201", :name "Antoine Bauza", :url "<http://www.antoinebauza.fr/>"} {:id "202", :name "Bruno Cathala", :url "<http://www.brunocathala.com/>"})

erwinrooijakkers 2019-02-21T13:08:39.002900Z

user&gt; (map {:a "a" :b "b" :c "c"} #{:a :b})
("b" "a")

erwinrooijakkers 2019-02-21T13:09:16.003500Z

Mapping a map over a set leads to the keys of that set extracted out of the map, which is logical

erwinrooijakkers 2019-02-21T13:09:19.003900Z

Now I see

erwinrooijakkers 2019-02-21T13:09:20.004200Z

Okay πŸ™‚

πŸ‘ 1
πŸ˜€ 1
hlship 2019-02-21T14:54:08.004800Z

Maps can acts like functions ... but perhaps the code in the tutorial is a bit too concise.

erwinrooijakkers 2019-02-21T14:56:39.006800Z

Yes I see now it uses (my-map &lt;:key&gt;), 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.

erwinrooijakkers 2019-02-21T14:57:09.007400Z

So I thought it was doing some set/map magic I did not know yet

erwinrooijakkers 2019-02-21T14:57:45.007600Z

But I am very happy with the example

erwinrooijakkers 2019-02-21T16:37:12.007900Z

Really really nice tutorial. Thanks!

2019-02-21T19:06:31.009300Z

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

2019-02-21T19:11:32.010600Z

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