that can kill efficiency in a sense, ideally you can just write more resolvers and always be as specific as possible about your requirements, this is the way to maximize the utility of how pathom can optimize your code paths to fulfill data needs
because if you give them as smart maps, you delay the point in which you know what you need
so each time you read, pathom has to go over the planning and running process again
while if you do in a single go, pathom can plan once, and with more information makes it more efficient (because it can optimize repeated paths and stuff like that)
"each time you read" - This means get
operations on the smart map?
yeah
doing a single query is much likely going to be faster than lazy loading one attribute at a time
I had that situation with Pathom Viz, I was using smart maps to compute trace data
Fair enough. Although, in my case, I think the only performance difference is Pathom's overhead to compute the plan. No matter what, I'm going to have to compute the result I care about. The only issue is whether the computation occurs as part of a smart-map get
or as a direct function call
I was feeling some perf hit, and switch over to a pre-defined query in EQL, that got around 8x faster (because there was a lot of collection items, in those cases the usage of smart maps to do one attr a time adds up)
what I'm telling you is mostly about my perf expectations, but I like to encourage you to play around with a mixed approach, and Pathom totally supports that
you can write a plugin to make this happen
Oh, that's a good idea. I had planned on each resolver wrapping input
in a smart map but a plugin is much more convenient
using the wrap-resolve
hook, there, you can wrap the resolver call by transforming the input in a smart map, them you get what you asked for
Perfect
This whole conversation brings to mind something I've been wondering about: Given smart-maps, what is the right balance between function calls on maps vs get
operations & resolvers
and I'm curious how this goes, would to learn more about what happens after some time doing that 🙂
function calls on maps?
I mean a function that takes a map as input
that's the design part, depends how much you want to delegate to pathom
or what "entry points" you wanna give to the system
I think a very open question, varies a lot
How to I get to the reader “input”s in a Pathom 2 wrap read plugin? All I see is env, and I’m not sure where the inputs would be
do I have to do my own “select-keys” on the entity atom for the reader?
@tony.kay you can't on wrap-read, but you can on ::pc/wrap-resolve
AH
wrap-resolve!
wrong wrapper!
yup, the wrap-read will wrap the call to the reader chain
wow, went too low-level and totally got stuck…so easy