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

Updating array embeds

https://ash-hq.org/docs/guides/ash/latest/topics/embedded-resources says this for Array embeds
All values in the original array are destroyed, and all maps in the new array are used to create new records.
All values in the original array are destroyed, and all maps in the new array are used to create new records.
Ecto has an api to update array embeds while keeping existing ids. Is there a way to do the same using Ash?...

AshPhoenix.Form for an Ash.Flow module instead of Ash.Resource

I really like AshPhoenix and I just figured out how to use Ash.Flow. Is it possible to initialize an AshPhoenix.Form object for an Ash.Flow module instead of the usual Ash.Resource?

Use Policy.SimpleCheck inside an expr

Right now I have the following policy: ```elixir policy action([...]) do forbid_if MarketsChecks.NotConfirmedYet...

Action macro with Ash queries

hey Zack, in the #ideas channel, you gave the idea of creating a macro in case I want to move an action logic to another module https://discord.com/channels/711271361523351632/712035333432147989/1075932613061116036 I did that and it seems to work great, but when I add some Ash.Query macros to it, then it stops working. The obvious reason should be that the macro is not finding require Ash.Query but I can't find a way to add it to make it work. This is what I have right now: ```elixir...

Where and how do I write my business logic?

I know this is a silly question and I apologize as I'm still new to Ash, but where exactly do I write my business logic? I have a Book and Category resource. What I want to happen is to create a bunch of Category records every time a Book is created. Normally, I would write this business logic in a context/module somewhere and then call it inside the save handle_event in my liveview after a successful Book record creation....

Set up testing

Is there any documentation on actually setting up testing? I want to test my resource before I begin trying to implement my ui, but I can't find how to create or run migrations for the "test" postgres db. I'm new to elixir and phoenix in general so any direction on where to go to find this information would be appreciated. My current test looks like ...
No description

:one_of constraint for type string

There exists :one_of constraint for type :atoms on the resources, but this does not exist for type :string. Is there another way to restrict values to one of a list of strings?

Auth0 and AshAuthentication

with AshAuthentication and auth0, what should I specify as the user resource attributes? like, email etc etc, what if I want different roles? i.e: admin users and normal users? can I specify a role attribute on the resource - and have that saved in auth0 somehow?...

Building can? function that supports filter checks

I am looking to build out a custom GQL query that allows my front-end to ask the backend whether it has permissions to do an action on a resource instance. I have already built this out to a resource level to the extent that the front-end can ask: "Can I perform this action on this resource type". Next up, I want to support asking "can I perform this action on this particular resource with ID = x". @frankdugan3 already added some canfunctions, which I am using in the above scenario. However I will need extra functionality so that in addition, the filter checks are taken into account. The reason is that some of my action policies use relates_to_actor_via. For the reads I suppose I could actually perform the read and use the result. However for :update there are also filter checks and I can't use that strategy. Any thoughts on how best to approach this? I have started looking into it however quickly got lost in the engine / request modules....

Make some calculation action specific

So, if I want to do a specific change for an action, I can always add , where: [action_is(:create)] or something like this. I tried the same for calculations but it doesn't seem like it has the same functionality. So, if I want to do a calculation that is only relevant for a specific action, is there some way to do it?...

Exposing data of the managed relationship

I created an action on Resource1 that creates another Resource2. Resource2 is created correctly using manage_relationship but I need to return the generated id for Resource2 and I have not found a way to get that information. Is it possible to access the return values from the action called by manage_relationship ? If they are accesible I could put them into metadata

Use `action/1` with more than one action in policies

Right now I'm doing my policies like this: ```elixir policy action(:some_action) do ......

Ash Relationships with existing Ecto Repos

Hi there, I'm currently working on integrating Ash into my existing Phoenix/Ecto/Postgres app. So far Ash looks amazing and seems to be exactly what I'm looking for - the power and balance of ecto but without having to create basic utility functions over and over and over again 😉 Sorry if my question has already been answered, I couldn't find anything on GH, google, docs or Discord. ...

Adding new field in default Ash_Authentication_Phoenix Registration Page.

how do I add new field in the registration form? I already update the user's resource attributes with :name, what the next step to make it appear in registration page?

Aggregate first the full resource instead of some field

I have a property resource that can contain offers. When I'm fetching the property, I want to also fetch the current offer from the actor if there is one. Right now, I have this:...

How to fetch the actor inside validations?

Basically I'm creating a validation that needs to actor to call another api, but the input changeset doesn't contain the actor.

Compile error: module Any is reserved and cannot be defined

Say I have the following resources: City: ```elixir myapp/lib/myapp/data/resources/city.ex...

When to use validations or policies

So, continuing the discussion from #general. Can you elaborate more about when should I use validation and when to use policies? If I got it right, seems like I should use policies for things related to the actor and validations to things related to some resource....

Fly.io deployment with ash_authentication

I'm trying to deploy the new version of my app with ash_authentication but I get an error at this line:
signing_secret(Application.compile_env(:todoish, TodoishWeb.Endpoint)[:secret_key_base])
signing_secret(Application.compile_env(:todoish, TodoishWeb.Endpoint)[:secret_key_base])
```...

AshGraphql generated mutations are bypassing schema middleware

I have this middleware in my GraphQL schema to check if the user is authenticated: ```elixir def middleware(middleware, field, obj) do if obj.identifier in [:query, :subscription, :mutation] and...