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

DISTINCT ON LEAST() GREATEST()

SELECT DISTINCT ON (LEAST(author_id, recipient_id), GREATEST(author_id, recipient_id)) id, text, author_id, recipient_id...

Ash.Query.filter creates filter with OR condition instead of AND

Ash.Query.filter function documentation explicitly says that a filter will be added with the AND condition, but it seems that this is not the case when fragments is used. For example, if I do this: ```elixir...

Generated filter expression is incorrect - BUG

Hello, I think I found a bug in Ash's query builder. I have the following filter expression in my resource action: ```elixir...

Filter by struct keys in a read action

So I have an ash actions. It receives a struct as an input. I want to create a filter that filters by values inside the struct. here's a simplified version of the action:...

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....