graph-gophers / dataloader

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

Passing query information to batch function? #70

Closed donecarlo closed 3 years ago

donecarlo commented 3 years ago

Is it possible to pass on the query information (specifically the fields requested) to the batch loader function? With my current implementation, the creation of the loader is done outside of the resolver (like other samples) and there is no way to pass the query information to the batch function from within the resolver function.

nicksrandall commented 3 years ago

Yes, you could do this but the exercise is left to the user. This is primary the reason we use interfaces as keys and not raw strings. This way, you can embed all the information you want in the key and then use that as part of your batch function.

donecarlo commented 3 years ago

@nicksrandall got it. Was able to implement a way around this. Thanks!