You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand the reason Batch exists.
I've written quite a few GraphQL services with Caliban and used ZQuery there define data loaders.
That said I've never looked behind the curtain until now.
I've read the docs section about Batch.. and I couldn't grasp it.
Then I went to read about ZQuery, hoping they had a better explanation and I couldn't understand it either..
So, pretty much all examples I saw come down to something like this:
val source = Batch.sourceSeq(myBatchProcessing)
val res = for
a <- Batch.eval(Seq(1, 2, 3))
b <- source(a)
yield (a, b)
Batch.run(res)
This leaves me unsatisfied, because why use Batch when I can call myBatchProcessing(Seq(1,2,3))?
I though that Batch should help me, well, batch stuff.
But in this example I had to batch all ids for it.
Something I tried then, hoping initially that it would work:
val source = Batch.sourceSeq(myBatchProcessing)
val res = for
a <- source(1)
b <- source(2)
yield (a, b)
Batch.run(res)
Which didn't batch. Of course it makes sense, because flatMap allows me to access the previous result..
All that left me puzzled. I must be missing something very obvious.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I understand the reason Batch exists.
I've written quite a few GraphQL services with Caliban and used ZQuery there define data loaders.
That said I've never looked behind the curtain until now.
I've read the docs section about Batch.. and I couldn't grasp it.
Then I went to read about ZQuery, hoping they had a better explanation and I couldn't understand it either..
So, pretty much all examples I saw come down to something like this:
This leaves me unsatisfied, because why use Batch when I can call
myBatchProcessing(Seq(1,2,3))?I though that Batch should help me, well, batch stuff.
But in this example I had to batch all ids for it.
Something I tried then, hoping initially that it would work:
Which didn't batch. Of course it makes sense, because flatMap allows me to access the previous result..
All that left me puzzled. I must be missing something very obvious.
Beta Was this translation helpful? Give feedback.
All reactions