I’m creating a common internal lib to interact with database via ecto and abstracting paper_trail
So, to avoid duplication of config as
config :database, repo: Repo config :papaer_trail, repo: Repo the lib would only retrieve config :database, repo: Repo and then set up :paper_trail underhood.
Then I created a module to get this config:
defmodule Database.RepoClient do def repo, do: Application.get_env(:database, :repo, Repo) end But I want to use this same value to set up :paper_trail, so I did this on :database config:
config :paper_trail, :repo, {Database.RepoClient, :repo, []} Then I tried to use in another application, configure :database as shown above, but then I receive compilation warnings:
==> database Compiling 6 files (.ex) warning: ServiceTemplate.Repo.all/2 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:20: Database.all/2 warning: ServiceTemplate.Repo.get_by/3 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:16: Database.get_by/3 warning: ServiceTemplate.Repo.get_by!/3 is undefined (module ServiceTemplate.Repo is not available or is yet to bedefined) lib/database.ex:18: Database.get_by!/3 warning: ServiceTemplate.Repo.one/2 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:12: Database.one/2 warning: ServiceTemplate.Repo.one!/2 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:14: Database.one!/2 warning: ServiceTemplate.Repo.query/3 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:22: Database.query/3 warning: ServiceTemplate.Repo.query!/3 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:24: Database.query!/3 warning: ServiceTemplate.Repo.reload/2 is undefined (module ServiceTemplate.Repo is not available or is yet to be defined) lib/database.ex:26: Database.reload/2 warning: ServiceTemplate.Repo.reload!/2 is undefined (module ServiceTemplate.Repo is not available or is yet to bedefined) lib/database.ex:28: Database.reload!/2 That makes sense once config are compiled before modules. My question is: there’s any way to avoid that?
There’s a pattern for that situation? We prefer to duplicate config or just let these warnings exist?