absinthe
absinthe copied to clipboard
[Feature suggestion] Pass context to the callback function of Absinthe.Resolution.Helpers.dataloader/2 options
Hello everyone!
According to the docs, the callback function of Absinthe.Resolution.Helpers.dataloader/2 options
Can be used to e.g. compute fields on the return value of the loader.
This is a very useful way of transforming the data.
I think it this function would benefit from being passed the context, in case the data transformation needed to e.g. take session state into consideration.
Like this:
resolve dataloader(source, callback: fn (result, _parent, _args, context) ->
{:ok, transform_data(result, context)}
end)
What do you think? Would a PR be welcome?
I can see value in that for some use cases. Instead of the context I think it makes more sense to pass through the resolution struct just like normal resolver functions.
Agreed. PR welcome.