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

Transactions

There appears to be several ways to handle transactions, but I'd like to really narrow in on a clean way to handle logging entries from within a transaction. Let's use a simple example such as a Post. So when I create a Post from a Phoenix LiveView, I'd like to call a wrapper action for it such as Post.create_with_log(%{title: title}) Then in my Post resource file, I could possibly: 1) Create a code_interface definition such as define(:create, args: [:title], action: :create_with_log)...

Keyset pagination doesn't seem to use default_limit value

I have this action: ```elixir read :list_by_address do argument :address, :string, allow_nil?: false...

Session params missing for oidc providers using response_mode: form_post (e.g. Azure AD)

I am trying to use the OIDC strategy with Azure AD. Now is Azure requiring to use response_mode: form_post. This requires that the POST callback endpoint is not under CSRF protection (similar to how pow_assent is doing it). The issue is that the user/<strategy> key is not in the session during the callback phase. Am I required to implement a server side session store as pow does it? See the setup below: ...

Testing: How to approach testing

Im trying to write some tests for my ash resources, and want to test errors in particular, is there a recommended way of going about this? The testing docs are a bit anemic, wonder if folks have some strategies here. In particular when matching on ash errors, I have to match on large error structs with the stacktrace. Is there a simplier way of going about this?

Why don't read actions filter by attributes?

Given a read action ``` code_interface do define :read end...

warning: Changeset has already been validated for action :create.

I am getting this warning when trying to set an attribute before submitting a form, since this isn't user provided and I don't want to make the http call if this isn't going to be submitted, is there maybe another way to accomplish this as the warning says this will be an error in the future. ``` case AshPhoenix.Form.submit(socket.assigns.form, params: params, before_submit: fn changeset ->...

Should I use old-fashioned DB lookup tables? What might be some alternatives?

I realize not all mapped values are the same. Some have a very small set number of KVs (int id => 5-point scale). Some have a larger (int id => country code). Some have an indefinite set of KVs. In which cases (if not all) would you recommend DB lookup tables with Ash relationships. Would you recommend an alternative? I had considered for small sets to use a calculation, but I think that works with reads but not writes, right?...

How to: Conditional validation with built-ins

Im trying to validate an embedded field "payment_method" when a certain param/attribute has a specific value. I've tried to do this: ```elixir accept [:collection_method, :billing_cycle_anchor, :customer, :payment_method] validate present([:collection_method, :customer])...

AshCsv - duplication on `upsert?: true`

I might be doing something wrong but when using AshCsv with upsert?: true on a create action, I get duplicates in the CSV file. For context, here's the ressource ``` elixir ...

Does Api.bulk_create support action's arguments?

I'm try to create items that are related to the workspace by using bulk_create ```elixir create :create do primary? true...

Add conditions to upsert

Is there any way to add conditionals when doing an upsert in a create action? For example, I have this resource: ```elixir...

Calculations in AshJsonApi?

Just want to make sure I'm not missing anything obvious - is it possible to include a calculation in a JsonApi request? Including one in the includes list seems to imply it's only looking for resources:
No description

help with ash_geo for using locations.

Resource definition looks like ```elixir defmodule CompaniesRegEx.Resources.Recruiters do use Ash.Resource, data_layer: AshPostgres.DataLayer...

Creating index from identity or custom index creates bad migration

When generating a migration from either an identity or custom index, I'm getting a weird migration: Datalayer: ```elixir postgres do table "plans"...

AshJsonAPI Responses

When updating a resource backed by jsonapi, responses return a 201 instead of 200, is this a bug or am I doing something wrong?

Filtering many_to_many relationships

Hi all I have a many_to_many relationship between two entities (hubs and adverts). I want to have an action that takes an advert_id and returns the hubs to which it's attached to....

Key :editing_tenant not found

Just starting to explore AshAdmin. ```elixir ** (KeyError) key :editing_tenant not found in: %{ changed: %{...

Prefixed base62 UUIDv7 primary key implementation with Ash

Hi all, I'm trying to implement a UUIDv7 based primary key for all our Ash resources (and relationships), storing that as UUID type column on PostgreSQL and presenting that outside as a prefixed base62 string (0188aadc-f449-7818-8862-5eff12733f64 will be shown as acct_02tRrww6GFm4urcMhyQpAS), like what is described here for Ecto (https://danschultzer.com/posts/prefixed-base62-uuidv7-object-ids-with-ecto). I'll be happy to contribute with the result of this as a code sample or better as an elixir package as soon as I get it all working properly. ...

What is the __metadata__ field in new versions of Ash?

I just updated my Ash to the latest version 2.13.2. After that, I noticed that a lot of my unit tests stopped working basically because I was comparing resources. From what I can see, when I create the resource, the __metadata__ field will be a empty map %{}, but when I fetch the same resource with a read action, it will contain a key called selected in that map with the list of fields that were selected....

Need a feature for customizing error message.

i.e. in string type, match constraint will return error message "must match the pattern %{regex}". But, showing regex in user interface is not a good experience for users. I need to customize error messages....