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

Seeding multiple resources with inter-relationships

How do I do something like this in Ash? User and Post are Ash resources where a User has many posts. It doesn't seem to work as it does in Ecto. ``` Repo.insert! %User{ name: "John", posts: [%Post{...

How do you set an attribute to the join resource when creating?

For example, I have a User and an Org, joined by a many_to_many through a Join Resource UserOrg. UserOrg has an attribute :role. How do I set the role on the UserOrg when creating an Org? ```elixir...

AshAdmin Liveview is crashing

Hi! I'm seeing a lot of errors like this in my Phoenix logs when I'm viewing the AshAdmin page for the read action of my resource: ```elixir [error] GenServer #PID<0.793.0> terminating ** (FunctionClauseError) no function clause matching in Kernel.get_in/2...

Pagination 'count' is not accurate if the SQL query result contains duplicate id's

The pagination count SQL query is using DISTINCT like this:
SELECT coalesce(count(DISTINCT t0."id"::bigint), $1::bigint)::bigint FROM (...) ...
SELECT coalesce(count(DISTINCT t0."id"::bigint), $1::bigint)::bigint FROM (...) ...
If the result set returned by the sub query has duplicate ids then the count doesn't reflect the actual number of rows returned by the sub query because DISTINCT is removing them from the count....

Found read action while expecting an action of type relationship...

Hi, I need to customise a relation get the following error when trying to implement something like relationship(:events, :events_by_extid): ** (ArgumentError) Found an action of type read while looking for an action of type relationship The message itself is pretty obvious, but I can’t find a definition of how a relationship action would look like… 😇...

Override/Extend AshAuthentication Sign in

On submitting user credentials, I want to do something(like a query on some resource) before user email and password validation, and if its successful I want put some stuff in the Process dictionary. How can I override/extend/hook-into the sign in actions in AshAuthentication? I know a can set stuff into the Process dictionary in the handle_success callback, but don't know where to put the other implementations. Thank you.

"Could not relate to actor, as no actor was found (and :allow_nil? is false)"

Resource tweet.ex's create action currently includes change relate_actor(author) which causes the above error when trying to seed some data with Tweet.create. Is there a way to use this action as is for the seeding (without creating another action without relate_author)?

Pass create changeset or inputs from it to Flow?

In my resource I have these two create actions: ```elixir create :create do primary? true...

Create a custom migration file

I need to create a custom migration file for Oban, something like this: ```elixir defmodule MyApp.Repo.Migrations.AddObanJobsTable do use Ecto.Migration...

Does Ash Auth support Google/Apple OAuth?

I think the title sums it up 😄

Integrate Oban to a flow

So, currently, I have this flow: ```elixir defmodule MyFlow do alias Marketplace.Markets.Property.Offer...

How can I add the flow actor as the actor of one of the steps?

This is my flow: ```elixir defmodule MyFlow do alias Marketplace.Markets.Property.Offer...

Which action to use to update/delete multiple rows at the same time?

I was wondering which action type should I use to update or delete multiple rows of a resource? For example, let's say I have a resource called Post, and I want to have an action where I update all posts from that user. At first glance, I would use the :update action for that. But it seems that both :create, :update and :destroy actions are only meant to run with only one resource/changeset at a time....

Rename the `result(s)` field if a GraphQL mutation output

Right now, if I create a mutation with Ash, the output data will be inside the result or results field (see image). Is there some way to me to customize that name without having to create the whole mutation by hand? For example, in the case of the image, I would like that instead of result the key would be offer...
No description

Load data from id for a policy check during a create action

I have a create action that will create a new Offer, that offer needs to be related to a Property, so one of the fields I accept as input is a property_id. In my policies, I need to check some of this property fields, meaning that I need to load that property and make it accessible to that action policies somehow. How can I do such a thing with Ash?...

Differences between ETS and Postgres

So my thinking right now is, I'm using ETS to build out all of my resources and basically the app for as long as I can get away with. I do realize there are some differences between the Postgres adapter and ETS such as when it comes to identities where you've to add pre_check_with. However, are there some major differences where Ash is not able to abstract away the data layer and the code would actually be different for the two? I just wanted to keep open the option of selecting a database later. Maybe PlanetScale (which is MySQL, but doesn't support foreign key constraints and has some other limitations too), or Postgres or SQLite. Of course I understand we'll have to figure out how to create a data layer for those as they don't exist in Ash right now, but maybe I could help with one of those if we decide to go that route?...

GraphQL query of resource stops working after upsert of it

This seems a little bizarre.. I have this in my seeds.exs: ```elixir super_user_args = %{ first_name: "Super",...

My AshGraphql journey

I'm trying to integrate Ash into an existing Phoenix project. I can see amazing work has been put into this project. Even so, my journey so far has been painful. I needed to design a GraphQL query that returns a list of things. They first question that arose was: What does the GraphQL query look like for a given Ash GraphQL query definition? Let's say I want to define a query that returns a list of tickets (as from the documentation example). So see in the Ash GraphQL Getting Started page, I can define a query like this: ```elixir...

Using encrypted email field with Ash Authentication

I was wondering, do you think it would be hard, or even possible with the current implementation to use an encrypted_email field the same way you have encrypted_name or encrypted_address with ash_authentication? Having the e-mail field not encrypted in the database really bothers me tbh....

How to create a partial index with Ash?

I was wondering, can I create a partial index using identities or some other way with Ash or should I just write a migration manually directly? For example, how can I do this partial index? ```elixir...