CompilerError - Undefined function dataloader

Hey there,
I want to use dataloaders in my code but getting compilation error:

(CompileError) undefined function dataloader/1 (expected SatoriWeb.Schema.Schema to define such a function or for it to be imported, but none are available)

However I’ve initialized everything in my code:

import Absinthe.Resolution.Helpers, only: [dataloader: 1, dataloader: 3]

//getting error on this line
field :wallet, list_of(:wallet), resolve: dataloader(Wallet)

Absinthe compiled deps:

      {:absinthe, "~> 1.7"},
      {:absinthe_phoenix, "~> 2.0"},
      {:absinthe_plug, "~> 1.5"},

Found a solution over here: Dataloader compilation error
Here solution is to have updated version but mine is 1.7

1 Like

Hi @lalarukh you need to add the dataloader dependency. The dataloader/1 helper is only generated in Absinthe if it detects that you have dataloader available. You’ll want to add it to your deps list, and then

mix deps.get
mix deps.clean absinthe
mix deps.compile
1 Like

Thanks for answeing.
Actually Its giving me this error while giving deps command.
I just switched between the branches ones, may be because of that getting no owner message.

That is very strange, it looks like you have a file permissions issue. I would rm -rf _build deps to start from a clean repository and then mix deps.get and so forth.

1 Like