This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-29
Channels
- # announcements (1)
- # aws (4)
- # beginners (45)
- # biff (4)
- # calva (13)
- # clojure (38)
- # clojure-europe (2)
- # clojure-nl (1)
- # clojure-norway (2)
- # clojure-sweden (8)
- # clojurescript (9)
- # conjure (1)
- # core-async (4)
- # fulcro (5)
- # graalvm (6)
- # gratitude (3)
- # hyperfiddle (10)
- # off-topic (40)
- # pathom (4)
- # portal (23)
- # releases (1)
- # xtdb (5)
I'm wrapping an API that returns IDs that could either be one "thing" or another. Is there a best practices how to work around that sloppy data structure?
{:name "foo", :contents [{:id 1, :type "person"} {:id 1, :type "group"}]}
I tried to add a content-to-person
and content-to-group
resolver that returns {:id 1, :type "person"}
to {:person/id 1}
and {:group/id 1}
depending on the :type
. But it's not guaranteed to contain a person
nor a group
so the eql-queries are rightfully barked at, when the data gets returned and a map doesn't contain a mix of both "things."
Or would one just add {:person/id 1, :group/id nil}
depending on the :type
and just return nil
for all additional attributes that can't be resolved?
I'm lacking a "Maybe" type to query on which would infect my internal data structure. 😐FYI: For now to not get stuck I've opted to use an enveloping type that gets me my relevant attributes. It doesn't feel clean, but for now it gets the job done.
union query?