dataloader icon indicating copy to clipboard operation
dataloader copied to clipboard

Pass association/batch_key to query function

Open Un3qual opened this issue 4 years ago • 2 comments

Would it be possible to add the association name to the options passed to the query function when using a custom query? For example:

Dataloader.load(loader, Post, :replies, post)

would pass %{assoc_name: :replies} or something similar to the opts parameter in the query function.

Un3qual avatar Oct 23 '20 02:10 Un3qual

@Un3qual can you elaborate on your use case?

benwilson512 avatar Nov 14 '20 13:11 benwilson512

It would be useful to easily be able to have different behavior for the query function depending on which association I'm loading.

Un3qual avatar Nov 17 '20 21:11 Un3qual

It's a lot less fragile if instead the options are passed in directly:

Dataloader.load(loader, Post, {:replies, %{some_option: true}}, post)

benwilson512 avatar Oct 31 '22 04:10 benwilson512