This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-09
Channels
- # adventofcode (132)
- # announcements (19)
- # babashka (7)
- # babashka-sci-dev (6)
- # beginners (46)
- # calva (25)
- # chlorine-clover (5)
- # cider (2)
- # clara (17)
- # clj-kondo (93)
- # clojure (2)
- # clojure-dev (4)
- # clojure-europe (12)
- # clojure-losangeles (3)
- # clojure-nl (7)
- # clojure-uk (4)
- # clojurescript (29)
- # conjure (6)
- # core-async (8)
- # cursive (16)
- # data-science (7)
- # datomic (1)
- # exercism (4)
- # figwheel-main (8)
- # fulcro (9)
- # graphql (2)
- # helix (1)
- # introduce-yourself (3)
- # jobs (3)
- # lsp (4)
- # malli (20)
- # minecraft (3)
- # nextjournal (62)
- # off-topic (16)
- # overtone (34)
- # pathom (5)
- # polylith (10)
- # portal (1)
- # re-frame (104)
- # reagent (29)
- # reitit (1)
- # remote-jobs (2)
- # rum (3)
- # shadow-cljs (22)
- # spacemacs (2)
- # sql (10)
- # tools-deps (17)
- # vim (13)
Hi, I'm relatively new to pathom, so I'm not sure how to frame this question but
How do I pass the results of a join to a resolver?
here's what I'm trying to do
I have a query [:patients]
that returns some data
{:patients
({:patient-id 2, :patient-name "John"}
{:patient-id 3, :patient-name "Tina"}
{:patient-id 0, :patient-name "Richard"}
{:patient-id 1, :patient-name "Eve"})}
I have another query that does a join [{:patients [:patient-name :bill]}]
to give me this
{:patients
[{:patient-name "John", :bill 250}
{:patient-name "Tina", :bill 90}
{:patient-name "Richard", :bill 100}
{:patient-name "Eve", :bill 120}]}
I want to take this result and sort this by :bill
how can I achieve this? what will the query look like and how do I write a resolver for this?
also, :patients
` has a separate resolver and :bill
has a separate resolver.
(I am on pathom2)
Thanks in advancethe query (resolver) that’s returning the joined data should take a parameter
that will specify the sort-key.
sample eql could look like this
[{(:patients {:sort-by :bill})
[:patient-name
:bill]}]
ah, I don't have a resolver that returns the joined data. the open-ident-reader does that for me. I just have two resolvers, one for :patient
and one for :bill
I should mention the bill resolver uses the :patient-id
to resolve the billing data for the patient ( I guess that's why the open-ident-reader resolves it for me)
there is no sorting built-in in Pathom, usually what I do is to sort the data after reading it (usually on the client side)
you have the option to use params
to implement sorting, but usually I recomend avoiding this, instead think if you really need a custom sorting, usually the lists tend to have a "natural order", which you should use in the resolver