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

select relationship

Resource relevant parts ```elixir relationships do belongs_to :debit_account, Budget.Account, allow_nil?: false belongs_to :credit_account, Budget.Account, allow_nil?: false...

Mix ash_postgres.create problem

When I run mix ash_postgres.create on my project, I get the following error message in the terminal console: mix ash_postgres.create ** (Protocol.UndefinedError) protocol Enumerable not implemented for Bbg.Bids of type Atom (elixir 1.14.3) lib/enum.ex:1: Enumerable.impl_for!/1...

Users getting logged out every few hours

I recently switched our auth from phx.gen.auth to AshAuthentication. The switch was very smooth and users didn't notice anything except for one detail: they're now getting logged out every few hours (exact time seems to vary). I've been going through all documentation and the Discord but haven't found anything related. The only thing I found was this option token_lifetime, changing the value hasn't helped so far, though....

Show calculations in Ash Admin

Is there a way to show calculations in the Ash Admin panel for a particular Resource? My use-case is I have a file stored on Google Cloud Storage, and I want to show the signed url in the admin panel. The signed url has to be calculated every time since it expires...

Multiple checkbox group with Ash Forms

Is there a recommended guide to implementing something similar to the checkboxgroup component featured in https://fly.io/phoenix-files/making-a-checkboxgroup-input/ but compatible with Ash's form helpers? I've been working through that guide but it doesn't seem to play nice with the resources and forms I have. Been trying to munge my data into the right shape and now I'm wondering if there's an existing component system for this I'm overlooking (I've heard about Surface but I'm under the impress...

Best way to skip tenant check on a query

In my app I have users and accounts. The accounts are tenants. Users have and belong to many accounts through memberships. I've made the memberships resource multi-tenant, but now the users can't load their memberships. Memberships are really co-owned. Should I remove the multi-tenancy? Or is there a way for a query to ignore the tenant check?...

AshAdmin.PageLive.__live__/0 is undefined

Hello I'm very new to the framework. I was trying to use AshAdmin for one of my resource but I get the error in the image...
No description

Union relationships

Hello i have 2 resources. Accounts and Payments. Each payment has 2 relationships to accounts...

Use API access token to login into LiveView

Currently my system has two different ways to login, one is from our frontend which uses a GraphQL mutation to do the login and the other is via AshAuthentication LiveSession for LiveView. This means that for GraphQL I send the access token in the header as a Bearer authentication, but for LiveView, Phoenix will actually sign that same access token with the csrf and store that signature into a cookie called _marketplace_key. What I want to do is to make both system login process seamless, meaning that if the user is logged from the frontend (which uses the GraphQL api), it will also automatically be logged when the user go to the LiveView part of the system....

No Such Relationship

I have a many_to_many relationship between Plan and Post. Plan is the source, the relationship is defined there. Post is the destination. PlansPosts is the join resource. It's all in the same api this time. I'm making a form with, and calling manage_relationship from, Post, and that's resulting in a Spark error: ``` (EXIT from #PID<0.95.0>) an exception was raised: (Spark.Error.DslError) [Panacea.Sites.Post] actions -> create -> commander_create -> change -> manage_relationship -> relate_plans -> plans:...

`many_to_many` error

`` ** (RuntimeError) Resource SwiftEco.Resources.Accounts.UsersCompanies is not in registry SwiftEco.Resources.Companies for autogenerated join relationship: :users_join_assoc Relationship was generated by the many_to_many relationship :users` ...

After spark major update, deep preload not working.

Sorry for short description only. With spark 0.4.12, 2 or more depth preload is working fine, but with spark 1.1.4 only 1 depth preload works. i.e.) - resource A has one resource B...

Splitting resource using AshStateMachine using `Spark.Dsl.Fragment`

What I was hoping to do was be able to split my state_machine block from the rest of the resource using Spark.Dsl.Fragment. Bit of a catch-22 though, because without using the AshStateMachine extension there's notransition_state to use in actions, but with it there's no definition for initial_states. This hasn't been an issue for anything else, because for other extensions like AshGraphql, AshJsonApi, etc. there aren't the same kind of interdependencies and the rest of the stuff doesn't seem to get hung up because it's all in core. Is this a case worth addressing somehow? I can see there being more extensions in future that would, e.g. similarly provide additional changes builtins, but also have their own DSL section large enough to want to split it....

Filtering relationships in `relates_to_actor_via` etc.

Have a number of cases that I'm looking to set up policies and/or filters that perform a deep (but simple) join where for some path components it's necessary to filter the relationship. It's not feasible to create a different relationship for each possible filter, and I wanted to make sure that for right now I'm looking at doing the join manually in a custom check/filter. Generally would be interested in the current thought process for supporting parameterized relationships, and whether this is one of the target scenarios that's intended to be addressed. Related:...

Create action with multiple nested resources

This is the action to register an account. There are 3 resources at play. An account has many memberships and every membership belongs to a user. The membership resource is simply as has_and_belongs_to_many with a role on it. When a new account is created, it should always create the account and membership for the owner/user. The user resource has an identity on email and is only created if the user doesn't already exist. What happens is the membership fails to insert because the user_id is nil....

Implementating auto-incrementing/sequence fields in Ash Resources

I'm working on a project and I need to implement auto-incrementing fields, for example an Issue Number, Invoice Number, Service Number etc. I was thinking of creating a sequence table to keep track of multiple auto-increment field counts. issue_number counts, invoice_number counts, service_number counts, etc. I want to make sure that the implementation is consistent and that the sequence table will not leave gaps, as some database implementations leave gaps when a transaction fails....

All extensions list.

In one of the talks i heard cqrs/commanded mentioned. Is there some package at least in beta or smth? And broader question is where are list of all extensions, even 3rd party? I understand that ash currently is pretty young and theres probably not much, but i see huge potential in reusability and having something like https://tailwindcomponents.com/ but for ash resources.

Publish :create, ["created", deeply_nested_item_id]

Let's say my resources have this relationship, chat_room has many posts which then has many comments. and I want to have this pub_sub definedin comment.ex. ```...

Nested embedded Resource Form

I have an embedded resource which contains multiple other embedded resources. When I use AshPhoenix.Form.for_update with forms: [auto?: true], the form created does not contain information about any of the embedded resources other than the first key. Right now I am adding the missing data like so ``` update_form = AshPhoenix.Form.for_update(styles, :update,...

Set error message on attribute using AshAuthentication.Strategy.Password.PasswordValidation

When a password validation fails on a liveview form submitted. How do I get an error on the :current_password attribute? ```elixir AshPhoenix.Form.submit(socket.assigns.password_form, params: params, actor: socket.assigns.current_user) ...