diff --git a/.tool-versions b/.tool-versions index fa20ca91..4b3bce44 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ erlang 27.0.1 -elixir 1.18.4 +elixir 1.20 pipx 1.8.0 diff --git a/lib/domain/domain.ex b/lib/domain/domain.ex index a6bb8c59..afe1f89e 100644 --- a/lib/domain/domain.ex +++ b/lib/domain/domain.ex @@ -156,8 +156,6 @@ defmodule AshGraphql.Domain do The entrypoint for adding GraphQL behavior to an Ash domain """ - require Ash.Domain.Info - use Spark.Dsl.Extension, sections: @sections, transformers: [ diff --git a/lib/graphql/errors.ex b/lib/graphql/errors.ex index 3021847d..f72a86d8 100644 --- a/lib/graphql/errors.ex +++ b/lib/graphql/errors.ex @@ -174,7 +174,7 @@ defmodule AshGraphql.Errors do {nil, []} {arg_type, arg_constraints} when arg_type != nil -> - unwrap_type(arg_type, arg_constraints || []) + unwrap_type(arg_type, List.wrap(arg_constraints)) _ -> {nil, []} diff --git a/lib/graphql/filter_handlers.ex b/lib/graphql/filter_handlers.ex index dd299c37..5b492053 100644 --- a/lib/graphql/filter_handlers.ex +++ b/lib/graphql/filter_handlers.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Graphql.FilterHandlers do alias AshGraphql.Graphql.Resolver - require Ash.Query - @boolean_keys [:and, :or, :not] @doc """ diff --git a/lib/graphql/phase/inject_metadata.ex b/lib/graphql/phase/inject_metadata.ex index c7b49004..edffcdbc 100644 --- a/lib/graphql/phase/inject_metadata.ex +++ b/lib/graphql/phase/inject_metadata.ex @@ -90,6 +90,9 @@ defmodule AshGraphql.Phase.InjectMetadata do end end + defp build_metadata(false, _info), do: {nil, nil} + defp build_metadata(nil, _info), do: {nil, nil} + defp build_metadata(true, _info) do Logger.warning( "AshGraphql response_metadata is set to `true` but requires a key. " <> @@ -148,9 +151,6 @@ defmodule AshGraphql.Phase.InjectMetadata do {key, nil} end - defp build_metadata(false, _info), do: {nil, nil} - defp build_metadata(nil, _info), do: {nil, nil} - defp build_metadata(invalid_config, _info) do Logger.warning( "AshGraphql response_metadata received invalid configuration: #{inspect(invalid_config)}. " <> diff --git a/lib/mix/tasks/ash_graphql.install.ex b/lib/mix/tasks/ash_graphql.install.ex index 7fdd0313..541a8b6b 100644 --- a/lib/mix/tasks/ash_graphql.install.ex +++ b/lib/mix/tasks/ash_graphql.install.ex @@ -6,7 +6,6 @@ if Code.ensure_loaded?(Igniter) do defmodule Mix.Tasks.AshGraphql.Install do @moduledoc "Installs AshGraphql. Should be run with `mix igniter.install ash_graphql`" @shortdoc @moduledoc - require Igniter.Code.Common use Igniter.Mix.Task @impl true diff --git a/lib/resource/resource.ex b/lib/resource/resource.ex index ad0ed282..8e3c3431 100644 --- a/lib/resource/resource.ex +++ b/lib/resource/resource.ex @@ -3038,9 +3038,6 @@ defmodule AshGraphql.Resource do defp on_lookup_fields(opts, relationship, schema) do case ManagedRelationshipHelpers.on_lookup_update_action(opts, relationship) do - {:destination, nil} -> - :none - {:destination, action} -> action = Ash.Resource.Info.action(relationship.destination, action) @@ -3053,9 +3050,6 @@ defmodule AshGraphql.Resource do field.identifier == relationship.destination_attribute end) - {:join, nil, _} -> - :none - {:join, action, fields} -> action = Ash.Resource.Info.action(relationship.through, action) diff --git a/lib/subscription/config.ex b/lib/subscription/config.ex index 75ded52d..7822da64 100644 --- a/lib/subscription/config.ex +++ b/lib/subscription/config.ex @@ -10,10 +10,22 @@ defmodule AshGraphql.Subscription.Config do """ alias AshGraphql.Resource.Subscription - # sobelow_skip ["DOS.StringToAtom"] def create_config(%Subscription{} = subscription, _domain, resource, relay_ids?) do - config_module = String.to_atom(Macro.camelize(Atom.to_string(subscription.name)) <> ".Config") + config_module = + Module.concat([ + resource, + Macro.camelize(Atom.to_string(subscription.name)), + Config + ]) + unless Code.ensure_loaded?(config_module) and function_exported?(config_module, :config, 2) do + create_config_module(config_module, subscription, resource, relay_ids?) + end + + &config_module.config/2 + end + + defp create_config_module(config_module, subscription, resource, relay_ids?) do Module.create( config_module, quote generated: true, @@ -82,7 +94,5 @@ defmodule AshGraphql.Subscription.Config do end, Macro.Env.location(__ENV__) ) - - &config_module.config/2 end end diff --git a/lib/subscription/runner.ex b/lib/subscription/runner.ex index 3dd77b07..fa7cb760 100644 --- a/lib/subscription/runner.ex +++ b/lib/subscription/runner.ex @@ -9,7 +9,6 @@ defmodule AshGraphql.Subscription.Runner do Mostly a copy of https://github.com/absinthe-graphql/absinthe/blob/3d0823bd71c2ebb94357a5588c723e053de8c66a/lib/absinthe/subscription/local.ex#L40 but this lets us decide if we want to send the data to the client or not in certain error cases """ - require Logger def run_docset(pubsub, docs_and_topics, notification) do for {topic, key_strategy, doc} <- docs_and_topics do diff --git a/mix.lock b/mix.lock index b838ccf6..3d8d1938 100644 --- a/mix.lock +++ b/mix.lock @@ -10,7 +10,7 @@ "decimal": {:hex, :decimal, "3.1.1", "430d87b04011ce6cbd4fd205be758311a81f87d552d40904abd00f015935b1d0", [:mix], [], "hexpm", "c5f25f2ced74a0587d03e6023f595db8e924c9d3922c8c8ffd9edfc4498cf1f6"}, "deep_merge": {:hex, :deep_merge, "1.0.2", "476aa7ea61c54de96220051b998d893869069094da65b96101aebf79416f8a1e", [:mix], [], "hexpm", "737a53cdc9758fedbb608bdc213969e65729466c4ef3cd8e8726d0335dff116c"}, "dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"}, - "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, + "earmark_parser": {:hex, :earmark_parser, "1.4.45", "cba8369ab2a1342e419bc2760eec731b17be828941dcf494045d44766227e1d5", [:mix], [], "hexpm", "d3ec045bf122965db20c0bdb420e19ee1415843135327124918473feb4b328e8"}, "ecto": {:hex, :ecto, "3.14.0", "2fa64521eebfcb2670d907a86e4ad947290e9933706bb315e6fb5c21b172cb26", [:mix], [{:decimal, "~> 3.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "130d69ffb4285f9ce4792b65dfbb994fd13ea4cbc3cbea2524b199aa3de84af3"}, "erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"}, "ets": {:hex, :ets, "0.9.0", "79c6a6c205436780486f72d84230c6cba2f8a9920456750ddd1e47389107d5fd", [:mix], [], "hexpm", "2861fdfb04bcaeff370f1a5904eec864f0a56dcfebe5921ea9aadf2a481c822b"}, @@ -26,7 +26,7 @@ "igniter": {:hex, :igniter, "0.8.2", "28621d9d2559c86a0249a195d9a7c55e8967b781850feff0bce6c4013b75f1c3", [:mix], [{:ex_ast, "~> 0.5", [hex: :ex_ast, repo: "hexpm", optional: false]}, {:glob_ex, "~> 0.1.7", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:jason, "~> 1.4.5", [hex: :jason, repo: "hexpm", optional: false]}, {:owl, "~> 0.11", [hex: :owl, repo: "hexpm", optional: false]}, {:phx_new, "~> 1.7", [hex: :phx_new, repo: "hexpm", optional: true]}, {:req, "~> 0.5", [hex: :req, repo: "hexpm", optional: false]}, {:rewrite, ">= 1.1.1 and < 2.0.0-0", [hex: :rewrite, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.4", [hex: :sourceror, repo: "hexpm", optional: false]}, {:spitfire, ">= 0.1.3 and < 1.0.0-0", [hex: :spitfire, repo: "hexpm", optional: false]}], "hexpm", "89146ad3fba21f3ea10873ae509fc760618623d4578e4723929a9dd1532aa30f"}, "iterex": {:hex, :iterex, "0.1.2", "58f9b9b9a22a55cbfc7b5234a9c9c63eaac26d276b3db80936c0e1c60355a5a6", [:mix], [], "hexpm", "2e103b8bcc81757a9af121f6dc0df312c9a17220f302b1193ef720460d03029d"}, "jason": {:hex, :jason, "1.4.5", "2e3a008590b0b8d7388c20293e9dcc9cf3e5d642fd2a114e4cbbb52e595d940a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0 or ~> 3.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b0c823996102bcd0239b3c2444eb00409b72f6a140c1950bc8b457d836b30684"}, - "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, + "makeup": {:hex, :makeup, "1.2.2", "882d46dc0905e9ff7abf2aab61a7e6b3dcc555533977d8a23b06019e6c89ac94", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "9a1a24e5b343b8ae16abea0822c10a6f75da27af7fa802ada5251f7579bfccfa"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, "makeup_erlang": {:hex, :makeup_erlang, "1.1.0", "835f7e60792e08824cda445639555d7bf1bbbddb1b60b306e33cb6f6db24dc74", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "1cd6780fb1dd1a03979abaed0fe82712b0625118fd5257d3ebbf73f960c73c3c"}, "mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"}, diff --git a/test/alias_test.exs b/test/alias_test.exs index 0cdf37e1..5fc4bc27 100644 --- a/test/alias_test.exs +++ b/test/alias_test.exs @@ -5,8 +5,6 @@ defmodule AliasTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/custom_paginate_test.exs b/test/custom_paginate_test.exs index b1acf999..df2ee03a 100644 --- a/test/custom_paginate_test.exs +++ b/test/custom_paginate_test.exs @@ -5,8 +5,6 @@ defmodule AshGraphql.CustomPaginateTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/lazyinit_post_search_test.exs b/test/lazyinit_post_search_test.exs index 7c9f3a6d..c625c21b 100644 --- a/test/lazyinit_post_search_test.exs +++ b/test/lazyinit_post_search_test.exs @@ -5,8 +5,6 @@ defmodule AshGraphql.LazyInitTestPostSearchTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/paginate_test.exs b/test/paginate_test.exs index b5e9a92b..1a52de55 100644 --- a/test/paginate_test.exs +++ b/test/paginate_test.exs @@ -5,8 +5,6 @@ defmodule AshGraphql.PaginateTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/plug_test.exs b/test/plug_test.exs index 05aa03ed..f74ca040 100644 --- a/test/plug_test.exs +++ b/test/plug_test.exs @@ -5,7 +5,6 @@ defmodule AshGraphql.PlugTest do @moduledoc false use ExUnit.Case, async: false - require Ash.Query import Plug.Conn @moduletag capture_log: true diff --git a/test/read_test.exs b/test/read_test.exs index 141a92eb..a9c4f5c9 100644 --- a/test/read_test.exs +++ b/test/read_test.exs @@ -5,8 +5,6 @@ defmodule AshGraphql.ReadTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/relationship_pagination_test.exs b/test/relationship_pagination_test.exs index dbb87ace..f438b053 100644 --- a/test/relationship_pagination_test.exs +++ b/test/relationship_pagination_test.exs @@ -5,8 +5,6 @@ defmodule AshGraphql.RelationshipPaginationTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/relay_test.exs b/test/relay_test.exs index f8c3bbc0..a9a38cec 100644 --- a/test/relay_test.exs +++ b/test/relay_test.exs @@ -5,8 +5,6 @@ defmodule AshGraphql.RelayTest do use ExUnit.Case, async: false - require Ash.Query - setup do on_exit(fn -> AshGraphql.TestHelpers.stop_ets() diff --git a/test/support/gf/attendee.ex b/test/support/gf/attendee.ex index bf8acaab..f9958701 100644 --- a/test/support/gf/attendee.ex +++ b/test/support/gf/attendee.ex @@ -13,9 +13,6 @@ defmodule GF.Attendee do extensions: [AshGraphql.Resource], authorizers: [Ash.Policy.Authorizer] - require Ash.Query - require Ash.Sort - alias GF.Member actions do diff --git a/test/support/gf/event.ex b/test/support/gf/event.ex index bc0e8c5c..40415a33 100644 --- a/test/support/gf/event.ex +++ b/test/support/gf/event.ex @@ -12,8 +12,6 @@ defmodule GF.Event do data_layer: Ash.DataLayer.Ets, extensions: [AshGraphql.Resource] - require Ash.Query - alias GF.Attendee attributes do diff --git a/test/support/gf/member.ex b/test/support/gf/member.ex index 6b9087ff..d88aaefd 100644 --- a/test/support/gf/member.ex +++ b/test/support/gf/member.ex @@ -4,15 +4,14 @@ defmodule GF.Member do @moduledoc false + require Logger + use Ash.Resource, domain: GF.Domain, data_layer: Ash.DataLayer.Ets, extensions: [AshGraphql.Resource], authorizers: [Ash.Policy.Authorizer] - require Ash.Query - require Logger - alias GF.ActiveMemberPolicy alias GF.Group alias GF.Types.MemberStatus diff --git a/test/support/relay_ids/resources/post.ex b/test/support/relay_ids/resources/post.ex index fc7e3aad..cfb799b4 100644 --- a/test/support/relay_ids/resources/post.ex +++ b/test/support/relay_ids/resources/post.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Test.RelayIds.Post do data_layer: Ash.DataLayer.Ets, extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :post diff --git a/test/support/resources/channel/channel.ex b/test/support/resources/channel/channel.ex index 1c2887d6..138606ca 100644 --- a/test/support/resources/channel/channel.ex +++ b/test/support/resources/channel/channel.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Test.Channel do data_layer: Ash.DataLayer.Ets, extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :channel diff --git a/test/support/resources/domain_level_pubsub_resource.ex b/test/support/resources/domain_level_pubsub_resource.ex index 9dcafc45..f54c76b6 100644 --- a/test/support/resources/domain_level_pubsub_resource.ex +++ b/test/support/resources/domain_level_pubsub_resource.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Test.DomainLevelPubsubResource do authorizers: [Ash.Policy.Authorizer], extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :domain_level_pubsub_resource diff --git a/test/support/resources/no_graphql.ex b/test/support/resources/no_graphql.ex index d911ae51..25f8e74a 100644 --- a/test/support/resources/no_graphql.ex +++ b/test/support/resources/no_graphql.ex @@ -9,6 +9,10 @@ defmodule AshGraphql.Test.NoGraphql do domain: AshGraphql.Test.Domain, data_layer: Ash.DataLayer.Ets + actions do + defaults([:read]) + end + attributes do uuid_primary_key(:id) diff --git a/test/support/resources/product.ex b/test/support/resources/product.ex index 9eef2609..55448e8c 100644 --- a/test/support/resources/product.ex +++ b/test/support/resources/product.ex @@ -9,8 +9,6 @@ defmodule AshGraphql.Test.Product do data_layer: Ash.DataLayer.Ets, extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :product diff --git a/test/support/resources/relay_subscribable.ex b/test/support/resources/relay_subscribable.ex index fd43795a..db70b523 100644 --- a/test/support/resources/relay_subscribable.ex +++ b/test/support/resources/relay_subscribable.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Test.RelaySubscribable do authorizers: [Ash.Policy.Authorizer], extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :relay_subscribable diff --git a/test/support/resources/resource_level_pubsub_resource.ex b/test/support/resources/resource_level_pubsub_resource.ex index aaf848fd..074fb50c 100644 --- a/test/support/resources/resource_level_pubsub_resource.ex +++ b/test/support/resources/resource_level_pubsub_resource.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Test.ResourceLevelPubsubResource do authorizers: [Ash.Policy.Authorizer], extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :resource_level_pubsub_resource diff --git a/test/support/resources/resource_with_typed_struct.ex b/test/support/resources/resource_with_typed_struct.ex index 736399fd..af375529 100644 --- a/test/support/resources/resource_with_typed_struct.ex +++ b/test/support/resources/resource_with_typed_struct.ex @@ -12,8 +12,6 @@ defmodule AshGraphql.Test.ResourceWithTypedStruct do data_layer: Ash.DataLayer.Ets, extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :resource_with_typed_struct diff --git a/test/support/resources/subscribable.ex b/test/support/resources/subscribable.ex index 4a23c0ef..d767389d 100644 --- a/test/support/resources/subscribable.ex +++ b/test/support/resources/subscribable.ex @@ -10,8 +10,6 @@ defmodule AshGraphql.Test.Subscribable do authorizers: [Ash.Policy.Authorizer], extensions: [AshGraphql.Resource] - require Ash.Query - graphql do type :subscribable diff --git a/test/support/simple_domain/simple_resource.ex b/test/support/simple_domain/simple_resource.ex index d01f7dea..96a051d2 100644 --- a/test/support/simple_domain/simple_resource.ex +++ b/test/support/simple_domain/simple_resource.ex @@ -8,4 +8,12 @@ defmodule AshGraphql.Test.SimpleResource do use Ash.Resource, extensions: [AshGraphql.Resource], domain: AshGraphql.Test.SimpleDomain + + attributes do + uuid_primary_key(:id) + end + + actions do + defaults([:read]) + end end