Mix phx.server error - (ArgumentError) missing :adapter option on use Ecto.Repo

I’m new to api with Elixir and when I write mix phx.server in the project I get an error like this

== Compilation error in file lib/blog_app/repo.ex ==
** (ArgumentError) missing :adapter option on use Ecto.Repo
    (ecto 3.7.2) lib/ecto/repo/supervisor.ex:57: Ecto.Repo.Supervisor.compile_config/2
    lib/blog_app/repo.ex:2: (module)

my repo.ex file

defmodule BlogApp.Repo do

  use Ecto.Repo, otp_app: :blog_app

  @doc """

  Dynamically loads the repository url from the

  DATABASE_URL environment variable.

  """

  def init(_, opts) do

    {:ok, Keyword.put(opts, :url, System.get_env("DATABASE_URL"))}

  end

end
1 Like

You are missing the :adapter.

It would look something like this:

defmodule BlogApp.Repo do
  use Ecto.Repo,
    otp_app: :blog_app,
    adapter: Ecto.Adapters.Postgres
end

You can read more about the setup in the docs

1 Like

i am getting error

If you are getting an error, always show the error. We cannot see what you do not show.

(CompileError) module Absinthe.Ecto is not loaded and could not be found. This may be happening because the module you are trying to load directly or indirectly depends on the current module

Stacktrace:
│ (elixir 1.13.3) expanding macro: Kernel.use/2
│ lib/blog_app/web/schema/types.ex:3: BlogApp.Schema.Types (module)

1 Like

This is now a very different error.
It seems you are trying to build a GraphQL API with Absinthe?

For better help, we need to see more of the project. Maybe a Github repo?
This might even be better under a new post, as the title of the post is resolved.

But if you don’t, I suggest you take everything out and build the project slowly.
Add Ecto, get it working, then Absinthe, then etc…

3 Likes