From a384247407b9f30958ef0e5dd4c6c8ff23c2dfd0 Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Mon, 7 Oct 2024 18:53:27 +0200 Subject: [PATCH 1/2] fix compile warnings because of igniter deprecations --- lib/domain/domain.ex | 2 +- lib/igniter.ex | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/domain/domain.ex b/lib/domain/domain.ex index 6ff7a4b2..e8c266ed 100644 --- a/lib/domain/domain.ex +++ b/lib/domain/domain.ex @@ -185,7 +185,7 @@ defmodule AshGraphql.Domain do ) end - Igniter.Code.Module.find_and_update_module!(igniter, schema, fn zipper -> + Igniter.Project.Module.find_and_update_module!(igniter, schema, fn zipper -> with {:ok, zipper} <- Igniter.Code.Module.move_to_use(zipper, AshGraphql), {:ok, zipper} <- Igniter.Code.Function.move_to_nth_argument(zipper, 1), {:ok, zipper} <- Igniter.Code.Keyword.get_key(zipper, :domains), diff --git a/lib/igniter.ex b/lib/igniter.ex index e7fef46c..abb5edd7 100644 --- a/lib/igniter.ex +++ b/lib/igniter.ex @@ -7,7 +7,8 @@ defmodule AshGraphql.Igniter do modules |> Enum.find(fn module -> - with {:ok, {_igniter, _source, zipper}} <- Igniter.Code.Module.find_module(igniter, module), + with {:ok, {_igniter, _source, zipper}} <- + Igniter.Project.Module.find_module(igniter, module), {:ok, zipper} <- Igniter.Code.Module.move_to_use(zipper, AshGraphql), {:ok, zipper} <- Igniter.Code.Function.move_to_nth_argument(zipper, 1), {:ok, zipper} <- Igniter.Code.Keyword.get_key(zipper, :domains), @@ -33,7 +34,7 @@ defmodule AshGraphql.Igniter do @doc "Sets up an absinthe schema for AshGraphql" def setup_absinthe_schema(igniter, schema_name \\ nil) do - schema_name = schema_name || Igniter.Code.Module.module_name(igniter, "GraphqlSchema") + schema_name = schema_name || Igniter.Project.Module.module_name(igniter, "GraphqlSchema") {igniter, domains} = Ash.Domain.Igniter.list_domains(igniter) @@ -59,7 +60,7 @@ defmodule AshGraphql.Igniter do {igniter, false}, fn {mod, arities}, {igniter, false} -> with {:ok, {igniter, _source, zipper}} <- - Igniter.Code.Module.find_module(igniter, mod), + Igniter.Project.Module.find_module(igniter, mod), {:ok, zipper} <- Igniter.Code.Function.move_to_function_call_in_current_scope( zipper, @@ -114,7 +115,7 @@ defmodule AshGraphql.Igniter do end igniter - |> Igniter.Code.Module.find_and_update_or_create_module( + |> Igniter.Project.Module.find_and_update_or_create_module( schema_name, """ use Absinthe.Schema @@ -132,6 +133,10 @@ defmodule AshGraphql.Igniter do mutation do # Custom Absinthe mutations can be placed here end + + subscription do + # Custom Absinthe subscriptions can be placed here + end """, fn zipper -> # Should never get here @@ -142,7 +147,7 @@ defmodule AshGraphql.Igniter do @doc "Sets up the phoenix module for AshGraphql" def setup_phoenix(igniter, schema_name \\ nil) do - schema_name = schema_name || Igniter.Code.Module.module_name(igniter, "GraphqlSchema") + schema_name = schema_name || Igniter.Project.Module.module_name(igniter, "GraphqlSchema") case Igniter.Libs.Phoenix.select_router(igniter) do {igniter, nil} -> @@ -179,7 +184,7 @@ defmodule AshGraphql.Igniter do @doc "Returns all modules that `use AshGraphql`" def ash_graphql_schemas(igniter) do - Igniter.Code.Module.find_all_matching_modules(igniter, fn _name, zipper -> + Igniter.Project.Module.find_all_matching_modules(igniter, fn _name, zipper -> match?({:ok, _}, Igniter.Code.Module.move_to_use(zipper, AshGraphql)) end) end @@ -189,7 +194,7 @@ defmodule AshGraphql.Igniter do Igniter.Libs.Phoenix.endpoints_for_router(igniter, router) Enum.reduce(endpoints_that_need_parser, igniter, fn endpoint, igniter -> - Igniter.Code.Module.find_and_update_module!(igniter, endpoint, fn zipper -> + Igniter.Project.Module.find_and_update_module!(igniter, endpoint, fn zipper -> case Igniter.Code.Function.move_to_function_call_in_current_scope( zipper, :plug, From 68e4c0e8475254dfa47e60ac94c134316f7c767b Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Mon, 7 Oct 2024 19:21:40 +0200 Subject: [PATCH 2/2] fix dialyzer --- lib/subscription/batcher.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/subscription/batcher.ex b/lib/subscription/batcher.ex index e1f9f128..a3f0738e 100644 --- a/lib/subscription/batcher.ex +++ b/lib/subscription/batcher.ex @@ -244,7 +244,10 @@ defmodule AshGraphql.Subscription.Batcher do [] end - {:error, error} -> + {:error, {_method, error}, _phase} -> + raise Ash.Error.to_error_class(error) + + {:error, error, _phase} -> raise Ash.Error.to_error_class(error) end