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

Confirmation broke, probably when the new confirmation button was added

When the confirmation button is clicked I see this error: ``` Plug.CSRFProtection.InvalidCSRFTokenError at POST /auth/user/confirm_new_user invalid CSRF (Cross Site Request Forgery) token, please make sure that: ...

Protecting against infinite loops on loading relationships

In my business domain I need to richly relate (i.e. with data on the relationship a resource with any number of resources of the same kind. I do this using a 'connector' resource, where the resource has_many connector forward_relationships and reverse_relationships, and the connector belongs to each of a source and target resource. So the source resource forward_relationship[]'s run through the connector resource an appear as reverse_relationship on the target. This enables me to model forward and reverse relationships independently, which is useful since they have independent lifecycles. The problem I'm having is that when I establish both forward and reverse relationships, if I have a load statement that loads relationships, then Ash will loop infinitely, exercising the datalayer over and over as it recursively loads resources it has recently loaded. As I mentioned the source and target resource are the same resource kind, so are constrained to have the same load statement....

AshPaperTrail - change module name and migrations are not genearted

1. Is it possible to change autogenerated module suffix Version to something different? 2. I have added AshPaperTrail and configured it to resource. But mix ash_postgres.generate_migrations --name add_paper_trail detect not changes so no new tables in migrations are added. And now I have error after updating resource that ERROR 42P01 (undefined_table) relation \"xxx_versions\" does not exist...
Solution:
I don't believe there is a way to customize the name right now no

[warning] Authentication failed: Query returned no users

🆘 Ash Authentication Policy Issue - SignInPreparation Query Failing I'm having trouble with Ash authentication where sign-in attempts fail with "Query returned no users" even though users exist in the database....

"Comparing values with `nil` will always return `false`" warning after updating ash 3.5.34 to 3.5.35

So I updated the deps today and I get a lot of these warnings. warning: Comparing values with nil will always return false. Use is_nil/1 instead. In: nil != {:_ref, [], :current_stop_id} (ash 3.5.35) lib/ash/changeset/changeset.ex:973: anonymous fn/2 in Ash.Changeset.atomic_default_condition/3 (elixir 1.18.4) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3...

Atom type `cast_stored/2` doesnt use `unsafe_to_atom?` constraint

The cast_input/2 function (https://github.com/ash-project/ash/blob/75a5d8617a5814b3113b9cb3c646dfc687b768dc/lib/ash/type/atom.ex#L86) for the Ash.Types.Atom allows for unsafe parsing of the input value. The cast_stored/2 function does not have this functionality: https://github.com/ash-project/ash/blob/75a5d8617a5814b3113b9cb3c646dfc687b768dc/lib/ash/type/atom.ex#L106 ...
Solution:
https://github.com/ash-project/ash/pull/2292 One CI check fails but that seems to be a transient issue...

AshPhoenix - Union: "is not a map" error

I can't figure out why these params don't work: ```elixir %{ "access" => %{...

GraphQL incorrect input generation

Hi folks, I've got a really weird one. AshGraphQL is generating incorrect inputs for one of my resources, and I'm completely stumped why. I've got a triple-nested embed, where the top level is PG, the rest are embeds. Component - attribute :colors -> ColorInfo...

How to test policies correctly?

Hello, I am confused a tiny bit about policy testing. As an example, right now what I do is the following: ```ex...
Solution:
You can use Ash.can or for code interfaces their can_ variant

AshCloak - How do I decrypt?

I can't for the life of me figure out how to decrypt and read back a value that's encrypted and stored with AshCloak. I'm sure it's very simple ... just ... ahhhh!!

Using AshAuthentication in an embedded React /JSON API setup

Good day! I am a recent Phoenix/Ash convert and having a lot of fun with the whole ecosystem. Thanks for all the hard work! I have a Phoenix application that renders a React SPA application on a static path like /app. The authentication works seamlessly. ...

Cannot find the right binding when sorting by fragment in many_to_many

``` has_many :semantically_similar, MODULE do no_attributes? true sort [...

Cinder doesn’t paginate

I’m trying to get cinder to paginate but it shows all data regardless. Cinder version: 0.5.5 <Cinder.Table.table...
Solution:
Does your resource definition enable pagination for the relevant action?

Can the Admin UI show calculations?

I have two resources; One acting as a course template and one for actualized, planned courses. Both have a price attribute with the intention that if an actualized course does not have a price it will use the default price from its template. This works fine when looking at the result of a read action in iex but the Admin UI doesn't want to show that calculation anywhere. Is this just not part of what AshAdmin is meant to do? This is not really a breaking issue as I will have to write my own dashboard UI on top of this anyway, it would've just been nice to be able to quickly check AshAdmin to see if changes in my resources work as intended....

Automatically Loading a Calculation by Default

Is there a way to always load a calculation by default without having to specify it every time?
Solution:
there is the build preparation you can use ``` read :read do prepare build(load: [:calculation])...

Execute an after_action only on single action or customize it for bulk actions.

Hello! I have an resource that must send a push notification when one of it's push notifications are updated. The problem is that I should aggregate bulk actions and send a single push notification in cases where multiple records go to the same user (which is the related resource). I tried to look on the internet and on this forum for a way to do that but couldn't find anything. But It would be something like sending a message saying that a user has "X 'something' to work on" (in case of bulk) vs saying "You have a 'something' to work on" and I don't want to spam the users with a message that meant to be sent for the single relationship update when we're doing bulks....

Possibly wrong `numericality` validation in `tunez` repo

Hello, I know this is a bit silly but considering that it's being accompanied by a book I thought I'd let you know that, unless I am misunderstanding something, in the Album Resource the year_released validation is slightly off. https://github.com/sevenseacat/tunez/blob/81078dc05cf42fa80945c33b6f90debab76700b2/lib/tunez/music/album.ex#L75-L80 The year must be in the range (1950, next_year), whereas currently it validates it to be in the range (1950, next_year]....
Solution:
huh. you're right! the message is slightly incorrect - but the code reflects my intention

Best way to handle actors/roles

Hi everyone! 👋 We’re working on a multi-app Phoenix project and could use some advice on unifying authorization actors. Setup...
Solution:
Gotcha, so normalizing them into a single struct makes perfect sense

How do I use a custom assign in the AshAuthentication success callback to work with Ash.Scope?

I’m using AshAuthentication and I have a success/4 callback in my AuthController that looks like this that is attempting to set the current_user key in the Scope object as part of the authentication confirmation flow: ``` def success(conn, activity, user, _token) do return_to = AuthRedirect.post_login_path(user)...

Recognizing Phoenix.Endpoint when using SiteEncrypt.

Would it be possible to recognize the endpoint if one is using SiteEncrypt?
The use statement is then use SiteEncrypt.Phoenix.Endpoint, otp_app: ... instead of the regular one. this causes packages like tidewave to not recognize the endpoint....