Hi guys! I have a document like:
{:foo/id "..."
:foo/a "1"
:foo/b "2"
:foo/c ["3" "4"]}
The keys foo/a, foo/b, foo/c are ids of the same table (call it table baz)
Now I would like to expand those keys with baz data.
To have something like:
{:foo/id "..."
:foo/a_expanded {:baz/id "1"}
:foo/b_expanded {:baz/id "2"}
:foo/c_expanded [{:baz/id "3"}
{:baz/id "4"}]}
What is the best way to group all the baz id and do one request to baz?hi @jean.boudet11, sorry the delay, not yet, but I made an issue so I dont lose track of it: https://github.com/wilkerlucio/pathom3/issues/231
from your other comment I guess you found this is done via batch resolvers?
Hi! Thanks to your answer. Yes, I already use batch resolver with async (promesa) but the overall eql process takes time (severals seconds). So I try to known if my resolver are ok. For context, I have mongodb documents with heavily nested resources. For the moment my strategy to "embed" resources is: • Each resources have a global batch resolver for example:
(pco/defresolver baz-batch-resolver
[env items]
{::pco/input [:baz/_id]
::pco/output [<baz-fields>]
::pco/batch? true}
(p/future
...)
• When I want a "join" I have this kind of resolver:
(pco/defresolver foo-a-expanded-resolver
[env item]
{::pco/input [:foo/a]
::pco/output [{:foo/a_expanded [:baz/_id]}]
{:foo/a_expanded {:baz/_id (get item :foo/a)}})
So from the previous example my eql looks like for example:
[:foo/_id
{:foo/a_expanded [:baz/_id :baz/name]}
{:foo/b_expanded [:baz/_id :baz/name]}
{:foo/c_expanded [:baz/_id :baz/name]}
Is this a good practise or is a bit complex?No worries @wilkerlucio. Thanks to create the issue
not sure if I fully understand, can you write me minimal reproduction so we get in the smae page?
Hi! You can find the repro here: https://gist.github.com/jeans11/7f03cdeee5552a6f868789c5483106b4
Hi! Any updates on this?