Ash JSON API is showing an error when following tutorial

Hello, after taking a break from Phoenix and Ash, I decided to move forward with my side project. When setting up the ash_json_api extension, I got the following error:
Compiling 18 files (.ex)
error: function plug/2 imported from both Phoenix.Router and Plug.Builder, call is ambiguous
lib/platform_web/router.ex:10: PlatformWeb.Router (module)


== Compilation error in file lib/platform_web/router.ex ==
** (CompileError) lib/platform_web/router.ex: cannot compile module PlatformWeb.Router (errors have been logged)
(phoenix 1.7.7) expanding macro: Phoenix.Router.pipeline/2
lib/platform_web/router.ex:9: PlatformWeb.Router (module)
Compiling 18 files (.ex)
error: function plug/2 imported from both Phoenix.Router and Plug.Builder, call is ambiguous
lib/platform_web/router.ex:10: PlatformWeb.Router (module)


== Compilation error in file lib/platform_web/router.ex ==
** (CompileError) lib/platform_web/router.ex: cannot compile module PlatformWeb.Router (errors have been logged)
(phoenix 1.7.7) expanding macro: Phoenix.Router.pipeline/2
lib/platform_web/router.ex:9: PlatformWeb.Router (module)
I added it to my Phoenix router like so:
use AshJsonApi.Api.Router,
apis: [Platform.Clinical],
json_schema: "/json_schema",
open_api: "/open_api"
use AshJsonApi.Api.Router,
apis: [Platform.Clinical],
json_schema: "/json_schema",
open_api: "/open_api"
I am using Phoenix 1.7.7 and Elixir 1.15.4. Is this a known thing or did Phoenix maybe change some internals? Thanks!
2 Replies
ZachDaniel
ZachDaniel2y ago
The ash_json_api router doesn't get added to your phoenix router it gets defined in a separate module, and then you forward to it from the other module
mylanconnolly
mylanconnollyOP2y ago
Ah that would explain it lol. Thanks!

Did you find this page helpful?