Ash Framework
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.
JoinAsh Framework
The Elixir backend framework for unparalleled productivity. Declarative tools that let you stop wasting time. Use with Phoenix LiveView or build APIs in minutes for your front-end of choice.
JoinError tenant required in calculation on tenant resource
Convenience functions for many_to_many relationships?
many_to_many
relationships. Given the resources below, what I'd like to do is have an add_to_hub
action in the User
module that takes in a Hub record and creates a corresponding UsersToHubs
record.
How would I go about setting up that action, and is placing a function like this inside of my User
resource module at all idiomatic for Ash?
I cut off the TestApp.Hubs.Hub
module due to character limit, but I set it up the same way as my User
module...many_to_many
example when I was reading the docs earlier.
So it's basically just:
```elixir
update :assign_to_hub do...Is it possible to prevent any direct use of Ash resource?
Form vs simple_form
simple_form
but when using Ash phoenix liveview generators, the regular form
is used by default. Is there a reason to use one vs the other? I incline to follow what the book does but I want to make sure this is the right decision.Global hooks
Using add_form with a many_to_many relationship
add_form
on a many_to_many
relationship. Here is my action and relationship.
```elixir
create :create_campaign_target_list do
primary? true...🔹 How to Regenerate a Specific Resource Using `ash.codegen` Without Affecting Others?
ash.codegen
(https://hexdocs.pm/ash/Mix.Tasks.Ash.Codegen.html) documentation but couldn't find an option related to this. I'm still in the early stages of development and sometimes make mistakes while defining resources (e.g. when generating multiple tables). When that happens, I want to regenerate just a specific resource from scratch, not create a new migration to fix it.
However, ash.codegen
seems to regenerate all active resources at once. To avoid that, I have to manually remove the files of the resource I want to regenerate and then run the generator again.
...Subscription to automated resource creation
Message
Resource and an Alert
Resource. We have a Ash.Notifier that on create checks if the message has the keyword "foo". If it is, we create an Alert
. If I have a subscription to the Alert
resource, should I expect that subscription to work even though it wasn't created from the frontend? I would assume yes but that is not what I'm experiencing....mark Ash.Resource extension attributes as public
extensions: [AshDoubleEntry.Transfer, AshGraphql.Resource]
extensions: [AshDoubleEntry.Transfer, AshGraphql.Resource]
AshDoubleEntry.Transfer
creates itQuery load and sort
locations
with a geometry field :geom
(using ash_geo + geo_postgis). When a user lands on a page and geolocates, the list of locations should sort ASC based on the user location and show the distance away in miles.
My current query is:
```
query...Enum.reduce
flipping the order later onWorking with AshArchival
Ash.Query.filter_input(query, %{"archived_at" => %{"is_nil" => false}})
Ash.Query.filter_input(query, %{"archived_at" => %{"is_nil" => false}})
:include_archived
action for example, exclude that action in the ash archival DSL, you can then pass action: :include_archived
to Ash.read
Forbidden magic link
dev/mailbox
but when I click it I'm taken to a page that has a "sign in" button, and once I click that, I get:
``` [warning] Authentication failed:
Bread Crumbs:
Error returned from: MyApp.Accounts.User.sign_in_with_magic_link...
Accessing_from policy not authorizing read preparation
Setting up a has_many relationship through another resource?
has_many(:comments, through: [:posts, :comments])
has_many(:comments, through: [:posts, :comments])
Ash Policies around :change_password action
User
resource with (mostly) the default update :change_password
action generated by the igniter installer,
```elixir
update :change_password do
# Use this action to allow users to change their password by providing
# their current password and a new password....Global Analytics
no_attributes? true
relationships but I'm getting some errors including
```
errors: [...Multiple confirmation strategies with interaction
require_interaction? true
with more than one confirmation strategy, because using the confirm_route
macro more than once produces a compile-time error.
confirm_route MyApp.Accounts.User, :confirm_new_user, auth_routes_prefix: "/auth"
confirm_route MyApp.Accounts.User, :confirm_email_change, auth_routes_prefix: "/auth"
confirm_route MyApp.Accounts.User, :confirm_new_user, auth_routes_prefix: "/auth"
confirm_route MyApp.Accounts.User, :confirm_email_change, auth_routes_prefix: "/auth"
as
optionOptional argument with defaults for actions
constraints: [allow_empty?: true]
Typed array attributes from `ash.gen.resource`
Setting attributes after getting data in before_transaction - calling validation in change_attribute
User
resource which requires email and a name. I want to expose a create type action on this resource, but all I have available when calling the action is a token. That token is in a 3rd party system, which returns the name and email. This resource has global validation on name and email, which I'd rather not change (or mark as before_action?: true
) since I do want them to be run up front for other actions.
What I was hoping to do is in a before_transaction
block, make the API call to get the data and set the attributes with change_attribute
, or put them in a context and call set_attribute
in a change block. However, when I do this, since the initial changeset doesn't have an email, it fails validation and the before_transaction never runs. If I pass in a placeholder email, I can get the before_transaction
to run, but then I get warnings when calling change_attribute
because the changeset has already been validated, and it's actually possible to pass in a bad email here and it'll get written to the database.
Another idea I had was to try and do this as a generic action, and then in the run block I would make the API call, get the user data, and then manually call the existing :create
. However, I need to return metadata (access tokens) for the user, but it seems like generic actions don't allow for metadata blocks, and since this action will be exposed via GraphQL, I'd want that typing of the metadata attributes on the query/mutation....