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

Tenant not being recognised in load after upgrading to Ash 2.9.21

Hi, I'm trying to upgrade to the latest version of Ash (2.9.21) and my tests are failing after the upgrade. In particular, I have code like this: ```elixir...

Run an create/update action without persisting the data

Is there any way to run a create/update action without persisting it to the db (I'm using postgres)?

Any way to validate a condition from a read actions instead of policies or filters?

So, normally I use filters modules when I want to validate something in read actions (ex. if I want to filter classes of a school (both resources), I pass the school_id and also filter it by checking if the actor is also from that same school. That kind of filter works great for most of the cases, but sometimes I just want to actually check some validation and return an error (or empty list if the error is not possible) without having the add that validation directly in the resulting SQL query. Normally, specially if the validation is more complex, I create a change module that does the validation and return an error if it didn't pass. But I can't use a change module in a read action....

Can't get policies to work with AshGraphql

I have an action, update_customer_registration, which requires a Customer actor. My Customer policy looks like this: ```elixir...

Querying JSON fields

I have this query, ```sql SELECT * FROM users WHERE settings->>'reminder_day' = 'Monday' -- Replace 'Monday' with your specific day...

get selected fields in create/update action

Hi, I have this policy to check if a user is only selecting fields that they are allowed to see. This worked well for reads because it was possible to get the selected/loaded fields from the query. Is it possible to do something similar for mutations ```elixir defmodule Demo.Policies.SelectsAllowedFields do @moduledoc """...

Test coverage for actions

Currently actions for resources can be defined in separate modules using fragments (with use Spark.Dsl.Fragment). During testing, these modules show 0% coverage. What is the best way to improve coverage for them? Same also goes for all resource modules (with use Ash.Resource)...

Possibility to have prepare statement for create, update, delete actions

Hi Zach Question I see that there a possibility to have a prepare statement for the read action but not for the others. Is there a possibility to add them in the future. If not what was the reasoning for it. Reason for asking was to inject the cache for all the actions...

Possible to add notifier to a resource from an extension on another resource?

Is it possible to dynamically (at compile time) add a notifier to a resource, from within the transformer of an extension on another resource?

Migration not keeping varchar size information

Not sure if I found a bug or not. But if I have this attribute in my migration: ```elixir...

What is the equivalent of Ecto's Repo.exists? in Ash?

Let's say I have a Post resource, and I want to create a read action that instead of returning a specific Post, I want it just to check if the post exists and return only true/false just like Ecto's Repo.exists? does. Is that possible with Ash?...

migration_defaults being "rewritten" by another resource

In my system, I have 2 contexts/apis that uses the same table and have a field in common. The first is the User resource inside the Accounts api: ```elixir...

GraphQL Relationship Resolved w/o Context

Hi there, 👋 I have a query like ```...

Intergrating Gaurdian Plugs into AshGraphql

I want implement JWT validation checking using Guardian. Is there an example I could checkout . For context this is for AshGraphQL and I want the check done only when certain actions are called not all. eg I have elixir ``` update :update_customer_registration do accept [...

Authentication.Plug - What to do as an API? I use Phoenix, but not with views. What is provided?

As I'm exploring and trying to setup AshAuthentication I ended up using use AshAuthentication.Plug for a plug, thinking this would provide the same set of routes as the Phoenix view version would, but it doesn't seem like it. I'm not even sure, as the docs aren't clear on this and I'm at this point digging in the code itself. Do I have to implement my own plug and controller(s) for this? I have an Angular frontend, and will maybe consume the same API from native apps later on. And also, does this mean that some features aren't available unless I use Phoenix?...

Auth0 confusion

Hello, I'm trying to setup ash auth with Auth0 I followed the tutorial but I don't understand how the "/auth" routes are created or how should I create them

Read Action Prepare does not load aggregate

I have a resource with a count aggregate for a child resource ``` aggregates do count :response_count, :responses end...

Calculation with arguments used in another calculation for sorting

I have a calculation that uses a postgres function to return a json object: ```elixir calculate :total_hours_report, Hsm.Ash.Payroll.TotalHoursReport,...

AshAuthentication: Set return_to from LiveView redirect to login page

As said in the title, where/how do I set the return_to parameter in AshAuthentication? If it's to be in the session, how do I set that in a liveview? Code snippets will be helpful....

Is it possible to pass a map to args instead of a list of attributes in code_interface?

I'd like to pull off something like: ```elixir actions do update :update_stats do...