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

Filter a change by action_type

I have a change that I want to apply to all the resource actions that are of type create, update and destroy. Looking at the Ash.Resource.Validation.Builtins I can only see the action_is/1 option which allows me to specific an action by name, but I can't find any action_type/1 options or something similar. Is that not possible?...

Use change manage_relationship without argument in create action.

I have a resource called User which has a has_one relationship with another resource called ImpersonatePermissions. When I create a new user, I want to also create a new in the impersonate_permissions table. To do that, I believe that I need to use manager_relationship. I was able to make this work with a custom change function: ```elixir...

Multi-Location + Multi-Tenant Read Replica

So we have a fairly complex requirement that we are hoping to solve via schema-based multi-tenancy and PG read replicas. As you can see from the diagram, we want to host the app in the cloud + 2 onsite locations matched to tenants. We would like to leverage read replicas to enable shared reads & local tenant writes in the event of internet/power outages at one of the on-site locations. Are there any immediately obvious problems with this idea, or does it seem feasible?...
No description

Multiple filters giving unexpected result

Say I have a data model similar to this: ```elixir defmodule Ht.Org do has_many :accounts, Ht.Account ...

Create relationship with itself

How can we add a relationship from some resource to itself? For example, let's say I have a User resource and I add a feature that an user can create another user, meaning that I want to add a field called created_by and created_by_id which is also an User...

Migration generator splitting composite primary keys

Before, I believe the recommendation was to do many_to_many relationships like so: ```elixir relationships do belongs_to :resource_a, App.ResourceA, primary_key?: true, allow_nil?: false belongs_to :resource_b, App.ResourceB, primary_key?: true, allow_nil?: false...

Reading Tenant ETS resources returns empty array

I am trying to read a tenanted ets resource but always getting empty list when trying to read, though creates are "successful". Below is my IEX session ``` Timshel.Ash.EtsComponent |> Ash.Changeset.for_create(:create, %{root: true}, tenant: "7473fdbc-4f04-4bbf-bf1f-c9721ebd18b6") |> Timshel.Ash.Api.create!() #Timshel.Ash.EtsComponent<...

Ash-Postgres and uuidv7

This might be an Ecto question. If I add a Postgres function uuidv7(), can Ash use it when creating new resource instances? If not, could Ash use such a function in Elixir (that would probably be faster anyway).

no FunctionClause matching when loading calculation

Hi, somewhere between this commit de943509f73ff0c6ef3749feb3cc6ab6e4d99d2d and now, I started getting an error in one of my graphql queries. ``` [error] Task #PID<0.6039.0> started from #PID<0.6032.0> terminating ** (Ash.Error.Unknown) Unknown Error...

guide for using Ash.Flow and multi step user flow with retries.

Hi Jack. Thanks for the good work you have put so far.
I was looking at Ash.Flow and the step DSL feels what i Might need. Here is the Use case in detail: ...

Resource's DSL "metric" actions

Hi @Zach Daniel, related to yesterday's question (https://discord.com/channels/711271361523351632/1097912088296443904) I got a new hint: we're trying a full-spread ash adoption on our internal project and we're trying to use only resource's code-interfaces everywhere, but for yesterday count/1 I've to call api module directly. What about the idea of a new kind of action supported by ash resource's DSL for defining resource's metrics methods in a declarative way? ...

Refresh "calculations" during form.validate

This question is kind of similar to https://discordapp.com/channels/711271361523351632/1071883200378445854/1071883200378445854 However, that example is a simple calculation involving two of the readily available form fields, whereas mine isn't as simple in that one of the inputs needs an aggregation of counts from an embedded array field as shown below. I want to be able to display the remaining count of an item which would decrease as the user increases the usage count. ``` calculate :item_remaining_count,...

`mix ash_postgres.generate_migrations` key `:table` not found

``` mix ash_postgres.generate_migrations Extension Migrations: No extensions to install...

Identity on two attributes causing errors

I have an identity on two attributes (context, and token). I would expect this to require a unique context <> token. But it's not allowing duplicate contexts. Here's my resource: ```elixir...

Sorting with calculation result giver "Argument value is required" error

I have the following query: ```elixir Markets.Property.Offeror |> Ash.Query.filter(...

`AshGraphql.Error` not implemented

Looks like a policy error is being raised and not caught somewhere: `` [warning] fb1756e7-6a42-43c1-a11c-9758d305ac78`: AshGraphql.Error not implemented for error: ** (ErlangError) Erlang error: {%Ash.Error.Forbidden{errors: [%Ash.Error.Forbidden.Policy{scenarios: [], facts: %{false => false, true => true......

Ash.Query fragment inside a select?

Hello, I'm trying to replicate this query with Ash.Query: ```sql WITH constants (value) AS ( values ('hue') ) SELECT...

Patterns for Propagating Tenants to LiveComponents/LiveViews?

This is a Noob / organizational question. But I just added attribute multi-tenancy to my app. I have the correct tenant loaded on login, placed in the conns, and in the session via ash_authentication.phoenix.livesession. I am grabbing the tenant from session in a LiveView to be added to reads . For handle_events, and all LiveComponents which talk to the DB, I assume I'll need to pass the tenant in via assigns? Feels like it could get a bit messy, especially for LiveComponents. Does any...

How to make simple select count with Ash

Hi, maybe a noob question here 😅 but I'm wondering which is the right way of making a simple select count of my Users on a Postgres-based app. I could do that with MyApi.count(MyResource) but on the docs that method belongs to the ambigous Ash.Filter.ShadowApi module. ...

GraphQL Subscriptions

Are they on the roadmap? Is there an existing pattern for getting them going using Notifiers?