I have an ash resource called “Resource” and it is causing issues when I try to use Ash.load
since the function seems to expect a keyword called :resource
which is conflicting with mine.
It hasn’t been a problem when simply specifying it, like prepare build(load: [resource: [:tenant, user_tenant: [:user]]])
but I am now trying to limit which fields are selected:
MyApp.Management.ResourceSubscription
|> Ash.Query.for_read(:read, %{}, actor: current_user_tenant)
|> Ash.Query.filter(access_scope: :manage and is_nil(archived_at) and is_nil(resource.archived_at) and user_tenant_id == ^current_user_tenant.id)
|> Ash.Query.select([:resource_id])
|> Ash.load(resource: Ash.Query.select(MyApp.Management.Resource, [:id, :slug]))
|> Ash.read!()
which throws:
[error] GenServer #PID<0.175530.0> terminating
** (ArgumentError) Could not determine a resource from the provided input:
#Ash.Query<resource: MyApp.Management.ResourceSubscription, filter: #Ash.Filter<is_nil(archived_at) and is_nil(resource.archived_at) and user_tenant_id == "40d505c0-8edd-4431-850b-ca794d9c64dd" and access_scope == :manage>, select: [:resource_id, :id]>
(ash 3.3.3) lib/ash/helpers.ex:386: Ash.Helpers.raise_no_resource_error!/1
(ash 3.3.3) lib/ash.ex:1699: Ash.load/3