ash_postgres/test/support/resources/subquery/access.ex
Zach Daniel 37cc01957d
improvement!: 3.0 (#227)
* WIP

* chore: fix mix.lock merge issues

* improvement: upgrade to 3.0

* chore: remove `repo.to_tenant`

* chore: continue removal of unnecessary helper

* chore: use `Ash.ToTenant`
2024-03-27 16:52:28 -04:00

57 lines
1 KiB
Elixir

defmodule AshPostgres.Test.Subquery.Access do
@moduledoc false
alias AshPostgres.Test.Subquery.Parent
use Ash.Resource,
domain: AshPostgres.Test.Subquery.ParentDomain,
data_layer: AshPostgres.DataLayer,
authorizers: [
Ash.Policy.Authorizer
]
require Ash.Query
postgres do
repo AshPostgres.TestRepo
table "subquery_access"
end
attributes do
uuid_primary_key(:id)
attribute(:parent_id, :uuid, public?: true)
attribute(:email, :string, public?: true)
end
code_interface do
define(:create)
define(:read)
end
relationships do
belongs_to(:parent, Parent) do
public?(true)
end
end
policies do
policy always() do
authorize_if(always())
end
end
actions do
default_accept(:*)
defaults([:create, :update, :destroy])
read :read do
primary?(true)
prepare(fn query, %{actor: actor} ->
# THIS CAUSES THE ERROR
query
|> Ash.Query.filter(parent.visible == true)
end)
end
end
end