This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-23
Channels
- # adventofcode (16)
- # babashka (41)
- # beginners (31)
- # biff (1)
- # calva (9)
- # clj-otel (2)
- # clojure (124)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-europe (11)
- # clojure-nl (3)
- # clojure-norway (8)
- # clojure-uk (5)
- # clojuredesign-podcast (10)
- # cryogen (1)
- # cursive (4)
- # data-science (1)
- # datomic (12)
- # emacs (37)
- # events (2)
- # fulcro (13)
- # guix (1)
- # honeysql (1)
- # hyperfiddle (8)
- # jobs (1)
- # missionary (21)
- # overtone (3)
- # pathom (6)
- # polylith (1)
- # portal (1)
- # practicalli (1)
- # releases (1)
- # remote-jobs (13)
- # ring (2)
- # sci (14)
- # shadow-cljs (23)
- # squint (4)
Given that the data shape of a response matches the shape of the request, why is it that a request with multiple queries (in a vector) is returned as a map of keys to the values? Is there a way of getting a boundary-interface to return a response to a vector of queries in the order of the original request?
e.g.
(pathom [{[:t_patient/patient_identifier 14032]
[:t_patient/id :t_patient/nhs_number]}
{[:t_patient/patient_identifier 14033]
[:t_patient/id :t_patient/nhs_number]}])
=>
{[:t_patient/patient_identifier 14032] #:t_patient{:id 17490, :nhs_number "1231231234"},
[:t_patient/patient_identifier 14033] #:t_patient{:id 14033, :nhs_number "1111111111"}}
I have a situation in which I don't really want to use a placeholder to add nesting, but am running two queries with the same initial ident - the second has parameters set on one of the joins.
hi Mark, in this situation I would say you have many inputs, but still a single query. the way I suggest you handle this is by using an entity input, so you send a value that is a vector with all the entities you wanna query for, and them you query that vector, here is an example:
(ns query-many-entities
(:require [com.wsscode.pathom3.connect.indexes :as pci]
[com.wsscode.pathom3.connect.operation :as pco]
[com.wsscode.pathom3.interface.eql :as p.eql]))
(pco/defresolver patient-nhs-number
[{:keys [t_patient/patient_identifier]}]
{:t_patient/id (str "ident - " patient_identifier)
:t_patient/nhs_number (str "nsh number - " patient_identifier)})
(def env
(pci/register [patient-nhs-number]))
(def request (p.eql/boundary-interface env))
(comment
(request {:pathom/entity {:patients [{:t_patient/patient_identifier 14032}
{:t_patient/patient_identifier 14033}]}
:pathom/tx [{:patients [:t_patient/id :t_patient/nhs_number]}]}))
does that work for you?
Thanks @U066U8JQJ - I'm trying an experiment and one query will be normalised, but another on the same ident will be pulled in denormalised - but I think I'm probably going in the wrong direction. Thanks you for suggestion however!