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?
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?
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.
Thanks @wilkerlucio - 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!