Fork me on GitHub

@wilkerlucio Hey thank you so much for building this great framework. I have a couple questions 1. Say I have records with

[ {:value "A" :record.created-by-id "123" :record.last-modified-by-id "456" }
  {:value "B" :record.created-by-id "789" :record.last-modified-by-id "456" }]
and then I have a service that does a batch lookup for users. What is the recommended way of setting this lookup up if I would like to return something that assigns a name to both created-by and last-modified-by I am sure this is a common problem šŸ™‚. We have a lot of leeway with the shape of the returned data, though we do need a batch lookup. One will be ideal, we can def live with two (one for created one for last-modified). We do need to be able to tell which one is which. 2. We are starting development now. How alpha is Pathom3? I saw someone asking about parallel parser and such. We are not shy about using alpha (got a lot of mitosin floating on the project), but would thought I would ask. Once again thanks for all your hard work.


hello šŸ™‚ 1. not what you want to do, what you mean by assign a name to created-by and last-modified-by? how these data is related to the records you presented? 2. Pathom 3 has a mostly stable API already, not expecting that to have big changes, that said, the basic features (local processing and serial process) seem to be stable, I've been using in a couple of projects and there are other users here too. I would say that features like distributed graphs is the one to not have a lot of confidence at this point, not very used and likely to be bugged at this stage


ok to be specific: I am modelling a resolver that gives me

[{:record/id "42" :record/created-by-id "user-id-1" :record/last-modified-by-id "user-id-2" ]
and so on I also have an api that can look up usernames in bulk so I can pass in
["user-id-1" "user-id-2"}]
and get back
[{:user/id "user-id-1 :user/display-name "Billy Bob"}
 {:user/id "user-id-2 :user/display-name "Jane Smith"}]


So what I am trying to do here is return something like

{:records [ {:record/id  "42" 
             :record/created-by-name "Billy Bob"
             :record/last-modified-by "Jane Smith"}]


once again it does not need to be this shape, just as long as I can navigate to the name


for each created-by and last-modifed-by


these values appear on 90% of our data, which needs to be displayed with the name on the UI


cool, the trick is to change your bulk input, and label the data you already have, so instead of ["user-id-1" "user-id-2"], it would be more like: [{:user/id "user-id-1"} {:user/id "user-id-2"}]


I have that


I have the batch resolver working


that sounds correct to me, whats the part I can help you with?


I did an alias between :record/created-by-id and :user/id


but I have 2 "user/ids" on each of this record


one for created by and one for last modified by


, how do I get both names to return for each record


I set up 2 aliases to map from created-by-id and last-modified-by-id for user/id


but when I write my query I can only get 1 of the mappings


here is my actual query

[{:notes [:note/id :note/created-by-id 


there are two issues here. I don't know which one the user/display-name is (created by or last modified by)


and only 1 is selected


I tried to model it with a join [{:note/created-by-id [:user/id]}]


but that does not work in batch


because the query results are nested now


I am asking because I think that this is an easy problem and I am just a noob šŸ™‚


(pc/defresolver note-test-resolver [_ _]
  {::pc/output [{:notes [:user/id]}]}
  {:notes [{:note/id               "123"
            :note/created-by-id    "0495e640-b11c-4b58-a29d-8ce0ba485144"
            :note/last-modified-by "04bfa00e-d161-46b4-b2cf-d829905c86db"}
           {:note/id               "789"
            :note/created-by-id    "047ab33e-fef2-4c3d-9d36-f8d3b0170525"
            :note/last-modified-by "047893f7-e697-436f-8259-2b6e0ae45c1d"}
           {:note/id               "456"
            :note/created-by-id    "170aa5c2-bcab-4cc3-990e-2e67f996fc58"
            :note/last-modified-by "d85c0a12-22ff-40a2-a050-811606ee375e"}]})


(pc/defresolver user-resolver [_ -inputs]
  {::pc/input     #{:user/id}
   ::pc/output    [:user/display-name]
   ::pc/transform pc/transform-batch-resolver}
  (let [inputs (if (sequential? -inputs) -inputs [-inputs])
        users  (get users from db)
        items  (map (fn [user] {:user/id           (:id user)
                                :user/display-name (:display-name user)
                                :user/email        (:email user)}) users)]
    (pc/batch-restore-sort {::pc/inputs     inputs
                            ::pc/key        :user/id
                            ::batch-default (fn [] {:user/display-name "NO-NAME"})} items)))


(def registry
  [ note-test-resolver user-resolver
   (pc/alias-resolver :note/created-by-id :user/id)
   (pc/alias-resolver :note/last-modified-by-id :user/id)


this is how I set it up


if it were just created-by I needed to lookup there would be 0 questions


no worries, taking a look at your text now


if you have multiple options for one attribute, there will be ambiguity (which is nice to avoid when you can), having a nested key for each (one for created, one for last modified) can be a way to solve the ambiguity


so in this case, you can have two extra resolvers, as:

(pco/defresolver nav-user-created [{:keys [note/created-by-id]}]
   [{:note/created-by [:note/user-id]}]}
  {:note/created-by {:user/id created-by-id}})

(pco/defresolver nav-user-last-update [{:keys [note/last-modified-by-id]}]
   [{:note/last-modified-by [:note/user-id]}]}
  {:note/last-modified-by {:user/id last-modified-by-id}})


then you can query:

[{:notes [:note/id {:note/created-by [:user/name]}]


please let me know how it goes


If I have an attribute marked as optional in my request, is it expected that Iā€™d get the Insufficient data calling resolver error message when trying to reach that attribute?


Do you have two resolvers that output the same attribute?


I think this is a planning bug. I've been meaning to create a repro case for it


great! ill try to create one as well. ill message here w/ the ticket when i do

šŸ™ 1

I think I got around it by avoiding optional entirely. I have one resolver that requires the attribute and one that does not. Then, I use priority to get the behavior that I want

šŸ‘ 1

the only way you may get that still is if some other required attribute depends on that, in this case it still invalid, otherwise please open an issue with a repro šŸ™‚