Ash Framework

AF

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.

Join

support

showcase

today-i-learned

How to create a second resource on a create action?

what is the best way yo create a second resource durning the creation of a first one? for example in a Workspace resource that should have a Wallet resource as has_one relationship...

How to set belongs_to on in a form

I have a create action for Plan that sets the Product (Plan belongs_to Product) ```elixir create :create do primary? true...

Policy authorizer not applying to read action

I have this policy ``` policies do policy always() do authorize_if action(:create)...

How to pass args to Api.read

I'm trying to accomplish something like this
Spendable.Api.read!(BudgetAllocationTemplate, action: :list, search: socket.assigns[:search])
Spendable.Api.read!(BudgetAllocationTemplate, action: :list, search: socket.assigns[:search])
for an action that looks like this ```read :list do...

Many_to_many on email destination

I'm try to create a many to may relationship between a workspace and a user, using user email instead of the user id. But when i try to create the a WorkspaceUser I get an error: ```elixir ** (Ash.Error.Invalid) Input Invalid * Invalid value provided for user: cannot provide structs that don't match the destination....

Invalid association, not an ecto schema

I'm getting a strange compile error that I can't replicate locally, only in GitHub Actions, I'm on the latest version of everything, ash deps, elixir and erlang. `` ==> spendable Compiling 5 files (.ex) warning: invalid association budget` in schema Spendable.BudgetAllocation: associated module Spendable.Budget is not an Ecto schema...

Can't add form with auto forms

I'm getting this error when setting up with auto forms. Attempted to add a form at path: [:budget_allocations], but no create_action was configured. here is my action ```...

Expected at most one result but got ...

I'm not sure if I've encountered a bug or not. I have the following action: ```elixir read :get do...

CRDT and Ash

First of all: Why use Ash? Because declarative programming and Elixir are awesome. Why CRDT? Because they are awesome too - anyone who's dealt with LiveViews losing their sockets knows what I mean. I'm using Rustler to talk to a Yjs (the package is Rjs which is pronounced 'wires'). A NIF written in Rust accepts an Ash resource instance and creates a Yjs document from it. I am contemplating how to do this in a generic way, and it appears that, while I might be able to code an Ash extension for this, it won't work with Rust serde. I'm contemplating using Json instead since it works bidirectionally between Ash and Yrs. Are there any gotchas I should be aware of when serializing Ash structs to Json? Would at least parts of JsonApi be of help? I haven't thought a lot about references yet but I think they will be links instead of being embedded. Every resource will have its own Yrs document. For now, this is just a fun experiment for learning CRDT and Rustler. Thanks!...

How to return custom errors in a after_transaction call?

Let's say I have a change with the following implementation: ```elixir def change(changeset, _opts, _context), do: Ash.Changeset.after_transaction(changeset, &do_change/2)...

How to use relationship id in a `get_by` read action

My resource has this relationship: ```elixir belongs_to :customer, Customer do allow_nil? true...

relationship required

Hey! Whats the best way to fix this error? ``` %Ash.Error.Changes.Required{ field: :account, type: :relationship,...

Action argument shows up as JsonString in graphql schema

I have this argument referencing another resource
argument :credentials, {:array, Credential}
change manage_relationship(:credentials, type: :direct_control)
argument :credentials, {:array, Credential}
change manage_relationship(:credentials, type: :direct_control)
however this argument is not showing the inputs that are available, is there a specific way to configure this so the input shows up correct in the schema?...

many_to_many with non-default attribute not preloading...

So, I have a many to many relationship I'm strugling with. It must be something silly, but I just can't make it work. I have a resource called Game, which is actually for a table called assets, so in the join table one of the attributes is asset_id and not game_id. The join table is called playlist_entries...

Looking for an example of an attribute-based custom filter check I once saw in an error message.

I saw once it in an error message, but can't find it anywhere online. It would correspond to this passage in the documentation, for create actions:
Keep in mind that, for create actions, many expr/1 checks won’t make sense, and may return false when you wouldn’t expect. Expression (and other filter) policies apply to “a synthesized result” of applying the action, so related values won’t be available. For this reason, you may end up wanting to use other checks that are built for working against changesets, or only simple attribute-based filter checks. Custom checks may also be warranted here.
Keep in mind that, for create actions, many expr/1 checks won’t make sense, and may return false when you wouldn’t expect. Expression (and other filter) policies apply to “a synthesized result” of applying the action, so related values won’t be available. For this reason, you may end up wanting to use other checks that are built for working against changesets, or only simple attribute-based filter checks. Custom checks may also be warranted here.
...

Hooking `manage_relationship`

Is there a way to specifically hook into manage_relationship, e.g. for an extension? I'm looking to get notified any time a relationship is added or removed.

Composing filter expressions

I'm trying to figure out how to reuse/compose (eg. apply a not) a complex expression that I use in filters. I have a complex filter expression that looks like this: ```elixir read :get_processed_for_visit do...

AshAuthentication error when trying to use password hashing change in seed action

I'm trying to use this action to seed some test accounts: ``` create :seed do accept [ :email,...

Can't use `actor` on aggregates

Hi - I'm trying to use ^actor on aggregates but it's throwing an error. This is my aggregate: ```elixir aggregates do first :max_index, :audio_files, :index do...

adding for update to a read action

I have an after_action block that performs a select using a read action. I'd like to turn that select into a "SELECT FOR UPDATE" - is that possible?