Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Feature suggestion] Pass context to the callback function of Absinthe.Resolution.Helpers.dataloader/2 options #1192

Closed
jstlroot opened this issue Sep 4, 2022 · 2 comments · Fixed by #1211

Comments

@jstlroot
Copy link

jstlroot commented Sep 4, 2022

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?

@maartenvanvliet
Copy link
Contributor

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.

@benwilson512
Copy link
Contributor

Agreed. PR welcome.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants