Fork me on GitHub
#pathom
<
2022-11-22
>
Panel02:11:34

Can I reuse the response from one query into another one in the same eql ? In the following eql I have multiple :herb.SearchResultDocument/id returned from the first search, I want to use the value into another search for each id, mapped as :taxonConceptId

[{'(:herb.Query/search {:input {:q          "*Eucalyptus*"
                                     :facetField ["taxonomic_status"]}})
       [{:herb.SearchResult/docs [:herb.SearchResultDocument/id  <-- USE THIS
                                  :herb.SearchResultDocument/scientificName
                                  :herb.SearchResultDocument/acceptedNameUsage
                                  :herb.SearchResultDocument/preferredVernacularName]}]}
 {'(:herb.Query/taxonConceptImages {:taxonConceptId "22ad8546-8f00-4999-9b20-e40d11229ad5" <-- HERE })
       [{:herb.ImagePaginator/data [:herb.Image/previewUrl]}]}]

Panel06:11:22

I can't see any example of resolved paras... I'm probably missing something, or I'm just supposed to do multiple queries. Not sure you can have “logic variables”in eql

Mark Wardle10:11:01

Hi. If I am understanding your requirement correctly, you could create a resolver to alias :herb.SearchResultDocument/id as :taxonConceptId - and then resolve any dependent properties from there, when possible. So you actually only make one request, but it is satisfied by a number of different resolvers. If your backing lookup service can resolve multiple at the same time, then you could use batch resolvers to optimise the multiple fetches required.

Mark Wardle10:11:59

If there is a 1:1 map between your search result document id and the taxon concept id, then you'd ideally want to flatten these resolvers at the top-level. For other requirements, you might nest the properties. I have resolvers that coordinate across multiple backend services in a single request using the results from one resolution in the processing of other requested attributes.

Mark Wardle10:11:55

Your alternative is to add a resolver that can take a :herb.SearchResultDocument/id and output a :herb.Query/taxonConceptImages attribute - or you could rename and abstract the how and think in terms of the API you wish to provide to clients, and simply resolve :herb.searchResultDocument/images and then have nested attributes that make sense in that context.

Panel00:11:13

Thanks for the explanation, I was using he dynamic resolver or graphql and just dropped that and wrote my own resolver that post json to a graphql endpoint.

Mark Wardle07:11:23

Hi. I wouldn’t necessarily remove dynamic resolvers, but simply use the first option I mentioned and alias one attribute for another. When pathom knows it can get from your search result id to a taxon concept id and using that can get all other requested attributes, it should work.

👍 1