dkarter
I’m working on a new project and trying to be very thoughtful about both the boundaries of my API and about reducing transitive compile dependencies (if that’s the correct terminology for this).
I read somewhere that one useful way to check for compile dependencies is:
mix xref graph --label compile-connected --fail-above 0
However it is failing under the following conditions:
I have 3 modules
MyApp.Schemas.AccountSchema
MyApp.Schemas.InstallRequestSchema
MyApp.Schemas.Base
MyApp.Schemas.Base is a __using__ macro used to set a bunch of repetitive settings that are shared between schemas such as binary ids, timestamp formats etc. It looks like this:
defmodule MyApp.Schemas.Base do
@moduledoc false
defmacro __using__(_opts) do
quote do
use Ecto.Schema
@foreign_key_type :binary_id
@primary_key {:id, :binary_id, read_after_writes: true}
@schema_prefix unquote(MyApp.Repos.Local.prefix())
@timestamps_opts [type: :utc_datetime_usec]
end
end
end
Which I then “use” in my schemas:
defmodule MyApp.Schemas.AccountSchema do
use MyApp.Schemas.Base
import Ecto.Changeset
# etc...
end
When running the xref check I get the following output:
❯ mix xref graph --label compile-connected --fail-above 0
lib/my_app/schemas/account_schema.ex
└── lib/my_app/schemas/base.ex (compile)
lib/my_app/schemas/install_request_schema.ex
└── lib/my_app/schemas/base.ex (compile)
This output makes sense to me.. but I wonder if there’s any to avoid this around it, or at the very least a way to tell xref command to exclude this particular module (without increasing the --fail-above counter which is error prone).
Or maybe I’m just thinking about this all wrong…
Anyway I’m hoping someone has bumped into this before and can share their insights.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 2 of 2 Posts
dkarter
This appears to be the offending line
Once I changed that to a static string the issue was resolved
I’m still trying to figure out why that was the case
al2o3cr
compile-connectedis looking for transitive compile-time dependencies; whenBasehas this line:then every module that does
use MyApp.Schemas.Basegets a compile-time dependency onBase(naturally) and transitively also onMyApp.Repos.Local.