Absinthe Dataloder process before return

Hi, when using the dataloader resolvers, in a nested query, is there a way to process the data previous to the return? I’m asking, because I have encrypted fields, that must be deencrypted previous to be returned.

Perhaps, you’re looking for a callback option in dataloader resolution helper.

3 Likes

@fuelen thanks! that’s what I’ve been looking for!

Hi. Is there a way to have all the accounts at once, I mean the list, instead one by one (because I see that the fn account -> {:ok, account.active}) does this one by one. I need to process every account, make an external API call, and then resolver with the complete list of accounts

Being final_all_accounts a list of users. Is this possible?

    field(:user, list_of(:user), resolve: dataloader(
      Accounts, callback: fn all_accounts, _parent, _args ->
        final_all_accounts = all_accounts |> deencrypt_sensitive_values
        {:ok, final_all_accounts}
      end
    ))