graph-gophers / dataloader

Implementation of Facebook's DataLoader in Golang
MIT License
1.21k stars 75 forks source link

What context is passed into batchFn? #80

Closed johnmaguire closed 2 years ago

johnmaguire commented 3 years ago

Load() may be called multiple times before batchFn is called. If Load() is called with various contexts, which one is ultimately passed to batchFn?

johnmaguire commented 3 years ago

It looks to me from this code here that it will be the first context object passed to Load() during a given batch window: https://github.com/graph-gophers/dataloader/blob/c87fdcead297022977fce66fbd3a6dde2261c32d/dataloader.go#L237-L245

This API is a little confusing - perhaps a note in the README would be helpful to clarify.

tonyghita commented 3 years ago

Thanks @JohnMaguire, that's right. A note on the README (and perhaps a comment on the code) could make this a bit clearer.