mirror of
https://github.com/ash-project/ash_graphql.git
synced 2024-09-20 13:24:14 +12:00
c3544dfe29
This keeps consistency with AshJsonApi, which generates its router in the web module namespace as well
28 lines
973 B
Elixir
28 lines
973 B
Elixir
defmodule Mix.Tasks.AshGraphql.Install do
|
|
@moduledoc "Installs AshGraphql. Should be run with `mix igniter.install ash_postgres`"
|
|
@shortdoc @moduledoc
|
|
require Igniter.Code.Common
|
|
use Igniter.Mix.Task
|
|
|
|
def igniter(igniter, _argv) do
|
|
igniter =
|
|
igniter
|
|
|> Igniter.Project.Formatter.import_dep(:ash_graphql)
|
|
|> Spark.Igniter.prepend_to_section_order(:"Ash.Resource", [:graphql])
|
|
|> Spark.Igniter.prepend_to_section_order(:"Ash.Domain", [:graphql])
|
|
|
|
schema_name = Igniter.Libs.Phoenix.web_module_name("GraphqlSchema")
|
|
|
|
{igniter, candidate_ash_graphql_schemas} =
|
|
AshGraphql.Igniter.ash_graphql_schemas(igniter)
|
|
|
|
if Enum.empty?(candidate_ash_graphql_schemas) do
|
|
igniter
|
|
|> AshGraphql.Igniter.setup_absinthe_schema(schema_name)
|
|
|> AshGraphql.Igniter.setup_phoenix(schema_name)
|
|
else
|
|
igniter
|
|
|> Igniter.add_warning("AshGraphql schema already exists, skipping installation.")
|
|
end
|
|
end
|
|
end
|