add `:default_vault` configuration
Hello :wave:
It has been brought to my attention through our tooling that the classic schema when using
Cloak.Ecto creates compile-connected dependencies between the schema and the vault.
Indeed, using field :field, CustomType creates a compile dependency to CustomType,
which, in this library's use case, has in turn a runtime dependency to MyApp.Vault,
creating a compile-connected dependency.
I tried to think of some ways to avoid this:
- One of the solution was to use an API similar to
:polymorphic_embed, and makeCloak.Ectorequire to use its ownfieldmacro, but I couldn't really figure out how to make it work honestly :no_mouth: - The second, much simpler solution, is to allow providing a
config :cloak_ecto, default_vault: MyApp.Vaultin the configuration, so that theCustomTypemodule does not have to reference theMyApp.Vaultmodule. That obviously does not cover the use-case where projects have multiple vaults...
I did a small PoC of the second option. I did not update the documentation, nor the unit tests, as I'm just asking your opinion on this option.
Thanks in advance!
In my opinion the vault should not be a genserver at all, but a module with it's own settings. See #62. Then automatically you won't have this issue