This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-24
Channels
- # aleph (1)
- # announcements (22)
- # atom-editor (11)
- # babashka (46)
- # beginners (60)
- # calva (44)
- # cider (18)
- # circleci (1)
- # cljdoc (12)
- # cljs-dev (5)
- # cljsrn (19)
- # clojars (3)
- # clojure (162)
- # clojure-dev (9)
- # clojure-europe (6)
- # clojure-italy (2)
- # clojure-losangeles (2)
- # clojure-nl (5)
- # clojure-spec (7)
- # clojure-uk (23)
- # clojureremote (1)
- # clojurescript (55)
- # community-development (14)
- # core-async (234)
- # cursive (14)
- # data-science (3)
- # datomic (32)
- # fulcro (5)
- # graalvm (20)
- # graphql (2)
- # hugsql (4)
- # jobs (11)
- # jobs-discuss (2)
- # joker (1)
- # juxt (3)
- # kaocha (1)
- # luminus (1)
- # off-topic (33)
- # pathom (3)
- # pedestal (1)
- # reagent (24)
- # remote-jobs (3)
- # shadow-cljs (38)
- # spacemacs (4)
- # specter (4)
- # speculative (54)
- # tools-deps (62)
- # vim (8)
- # vscode (14)
Question about data modeling with resolvers: I already know how to use the vector-collection format (or whatever it is called) for output.
::pc/output [{::s-coach/sessions
[::sf/id
::user/email
::s-coach/first-name
::s-coach/last-name
::user/visitor-id
::story/name
::session/id
::session/start-time
::session/location-url]}]
However, now I am building a resolver to enclose a more maplike existing data structure. e.g.
{:key1 {:a 1
:b "foo"}
:key2 {:a 3
:b "bar"}
:key3 {:a 14
:b "baz"}}
Is there a way to simply specify the output of this? Or do I need to restructure things to:
[{:id :key1
:a 1
:b "foo"}
{:id :key2
:a 3
:b "bar"}
{:id :key3
:a 14
:b "baz"}]
And use
::pc/output [{:my-collection
[:id :a :b]}]
?@austin021 hello, there is a feature to help with that coming on the next version, the ::pc/output
will remain the same (as you did), but you have to signal to Pathom that this map should be threated like a "map of maps", the distinction is nescessary because otherwise pathom would try to run the sub-query against the map directly (what you see happening now). this is an example of how to do use this:
(pc/defresolver some-resolver [env {:keys []}]
{::pc/output [{::s-coach/sessions
[::sf/id
::user/email
::s-coach/first-name
::s-coach/last-name
::user/visitor-id
::story/name
::session/id
::session/start-time
::session/location-url]}]}
{::s-coach/sessions
; add this metadata to the map, to signal map of maps to Pathom
^::p/map-of-maps
{:key1 {:a 1
:b "foo"}
:key2 {:a 3
:b "bar"}
:key3 {:a 14
:b "baz"}}})
you can try that using pathom 2.3.0-SNAPSHOT
, but this version may be unstable (not production tested, and a lot of changes there), use at your own risk