diff --git a/lib/ash/actions/read/read.ex b/lib/ash/actions/read/read.ex index 90ab41b05..882d0ee2d 100644 --- a/lib/ash/actions/read/read.ex +++ b/lib/ash/actions/read/read.ex @@ -473,7 +473,7 @@ defmodule Ash.Actions.Read do defp source_fields(query) do query - |> Ash.Query.accessing([:relationships]) + |> Ash.Query.accessing([:relationships], false) |> Enum.flat_map(fn name -> case Ash.Resource.Info.relationship(query.resource, name) do %{no_attributes?: true} -> diff --git a/lib/ash/code_interface.ex b/lib/ash/code_interface.ex index a1f6dd19d..179a4ed9c 100644 --- a/lib/ash/code_interface.ex +++ b/lib/ash/code_interface.ex @@ -588,7 +588,6 @@ defmodule Ash.CodeInterface do require Ash.Query {filters, params} = Map.split(params, unquote(filter_keys)) - query |> Ash.Query.for_read(unquote(action.name), params, query_opts) |> Ash.Query.filter(filters) @@ -641,7 +640,6 @@ defmodule Ash.CodeInterface do end else quote do - if opts[:stream?] do Ash.stream!(query, Keyword.drop(opts, [:stream?, :stream_options])) else diff --git a/lib/ash/query/query.ex b/lib/ash/query/query.ex index 8c280a581..5adfce300 100644 --- a/lib/ash/query/query.ex +++ b/lib/ash/query/query.ex @@ -996,10 +996,20 @@ defmodule Ash.Query do Provide a list of field types to narrow down the returned results. """ - def accessing(query, types \\ [:attributes, :relationships, :calculations, :aggregates]) do + def accessing( + query, + types \\ [:attributes, :relationships, :calculations, :aggregates], + only_public? \\ true + ) do query.resource |> Ash.Resource.Info.fields(types) - |> Stream.filter(& &1.public?) + |> then(fn fields -> + if only_public? do + Stream.filter(fields, & &1.public?) + else + fields + end + end) |> Stream.map(& &1.name) |> Enum.filter(&loading?(query, &1)) end