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

Reading private attributes stopped working

I recently started not getting back private attributes in my update action. Record looks good via Resource.read, but attribute is nil. Perhaps due to a recent regression or change in semantics?

Ash and AshPhoenix error key needs to be "foreign_resource_id", not "foreign_resource"..

There is a resource "A", and it includes belongs_to :foreign_resource, ForeignResource, and foreign_resource_id column. In phoenix liveview form, after validation I expect error with key "foreign_resource_id" needs to be exist, but only "foreign_resource" error exists. Can I get error with key "foreign_resource_id"?...

Rollback record with Carbonite

I'm trying to achieve the title result. The problem is that trying to set some fields (like foreign keys and timestamps) back to their previous values will mark the changeset as invalid. I'm using force_change_attributes to try to overcome the problem but it is not woking. Is there a way to force the changeset to accept all attributes changes without validating them? Or is there a better way to achieve what I'm trying to achieve?...

Ash Admin seems to be flakey

I'm having a pretty hard time using Ash Admin consistently. The view seems to randomly die and stop accepting updates. In the console I get messages that look like this: phx-F1UJhmZoL62MpQAj error: view crashed - undefined...

Custom validation error not appearing in form

I'm using the .input and .inputs_for components from Phoenix, and I see the normal is required errors in the html when I leave fields blank, but while my custom error shows up in the changeset from IO.inspect I don't see it in the html. The validation: ```elixir defmodule Panacea.Sites.Validations.ValidateHostname do use Ash.Resource.Validation...

Handling file uploads in AshGraphql and AshJsonApi

What's the current/planned support for handling of the :binary type in AshGraphql and AshJsonApi? I've been dealing with binary uploads using a more OOB approach, but would be curious to evaluate other options.

How to determine the cause of a form validation error

I have a couple of resources: ```` defmodule XrtConfiguratorApp.Template.Component do # Using Ash.Resource turns this module into an Ash resource. use Ash.Resource,...

protocol Enumerable not implemented for #Ash.Changeset

I apologize if I abuse the support channel, please tell me if I should take this to #general or #archive-debugging I've ran into this issue on two different resources, and I'll detail both below. The tl;dr is: I define a code_interface for a resource, but when I call the function it fails with protocol Enumerable not implemented for #Ash.Changeset<action_type: :create... at (ash 2.6.27) lib/ash/changeset/changeset.ex:998: Ash.Changeset.cast_params/3 Resource the first...

Ash Philosophy

"Declarative, Introspectable, Derivable" 1. "Introspectable" is related to Ash.Resource.Info module? The "Introspectable" characteristic is usually meaningful when developing library? 2. Does "Derivable" means "the execution of application code written with ash could be easily predicted."? I am preparing an ash in-house seminar, so I need to understand about this....

Where is the right place to perform transformation on form data before database insert?

Greetings, I have a form that will contain plain text in AsciiDoc format. I would like to convert the AsciiDoc to HTML and store it alongside the original in the database. I'm having a hard time understanding where the best place to do this is. I thought it would be a good candidate for an Ash Calculation, but the examples don't seem to deal with this kind of thing, so I wondered if it was an anti-pattern. In the spirit of "try the simplest thing that will work", I could just do it in the handle_events for creating and updating the resources. Is that a decent approach? Am I overthinking it?...

Check if an identity exists in a before_action

I'm not quite sure how to accomplish this in Ash: I'm uploading files to GCS and want to make sure if the hash of the file matches one I already have, I don't upload it again. The upload happens in a before_action on create right now. The hash of the file is an identity, and I thought eager checking would prevent the upload but it doesn't seem to. I'd like the create_with_binary to return the original record if it exists (without uploading) or upload and create a new record if necessary. So basically find_or_create....

Ash+Phoenix+Authentication Starter

I went through “Getting Started Ash Authentication Phoenix” yesterday, but if I want the “forgot password” flow, it looks like we should instead copy the dev subdirectory in the ash_authentication_phoenix repo and rename modules and directories. Is that the recommended way?

Kicking off an Oban job in the same transaction as an action

What's the right way to kick off an oban job in the same transaction as for example creating an ash?

Porting `cloak`-managed fields from Ecto schema to Ash

One of the Ecto schemas in my project uses Cloak to encrypt a value to a column on write, then decrypt the column on read and expose that on a virtual field on the schema. For example, the schema has these two fields: ```...

Resources without primary key not supported

I have this code: ```elixir defmodule Scribble.EmailHandler.User do use Ash.Resource use Ash.Resource, data_layer: Ash.DataLayer.Ets...

Lookups/calcultions based on has_many relationships

I will try to be very precise and concise, so apologies if this comes off rude-ish. - The history table contains a long list of entires that a user enters the application. Imagine like a list of chat entries. - The users can bookmark any number of those history entries - when retrieving a list of entries (e.g., last 40 entries, or all entries in a paged manner) I would like to try and in one go retrieve both the entries and whether they were bookmarked by this particular user...

`:ci_string` not becoming `citext` with `Ash.Type.NewType`

In my migrations:
add :email, :text, null: false
add :email, :text, null: false
I've solved this with casing: :lower for the example above, but there are fields where I'd like to preserve casing....

Bidirectional `manage_relationship`

Is there a way to get manage_relationship to manage the other side of the relationship simultaneously? Specifying destination_relationship: :other etc.

cannot use pin operator ^agg_authorize?

Hey guys, going through the tutorial but am getting the error above when compiling. im on ash 2.6.29

Conditional filters in read actions

Hi there, I'm back with another quesion that i couldnt find an answer to - sorry if i missed something. I have a resource with a list of form submissions, where i have a read action to get all form submission of a specific form id, with the form_id as an argument. that works fine. Now i also want to add the possibility to get all records submitted after a specific date, which also works this way: filter expr(submission_time >= ^arg(:min_submission_time))....