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 Spark to 1.1.17 breaks Ash.Flow transaction DSL

Ash version: 2.10.2 Spark latest working version: 1.1.16 Spark version that breaks: 1.1.17 Example code:...

Ash Graphql "create" mutation with upsert? true – how to use ID as argument for upsert identity?

I have a Graphql create mutation within which upsert? true and upsert_identity :id. I have an action corresponding to this (code below). Can I get id to be an acceptable input to this mutation? Thanks! ``` mutations do create :upsert_patient, :upsert_patient, upsert?: true, upsert_identity: :id end...

AshAuthentication identity :token_context

With the latest release of AshAuthention, I'm getting a DSL error. ``` (EXIT from #PID<0.96.0>) an exception was raised: (Spark.Error.DslError) [MyApp.Users.UserToken]...

Why there is no `Ash.Changeset.around_transaction`?

I was wondering why there is no around_transaction function in Ash.Changeset. We already have a around_action option, but that one runs inside a transaction, meaning that I can't use it if I wan't to add something to the DB regardless if the action itself fails or not. I know that there is a before_transaction and after_transaction, but depending on what I'm doing this would not work. Just to give a more concrete example....

no route found for POST /admin

With 1 ash_admin("/admin")` in the router.ex, I can open the admin site and see it perform some actions, but for some others, I get "no route found for POST /admin ". These are some simple read actions with a couple of arguments that I'm running, if that matters. Thanks.

Identities split into multiple resources doesn't seem to work

Not sure if I'm doing something wrong, but I have 2 resources that uses the same table, User and Customer. In my User resource I have these identities: ```elixir...

Create SQL queries for migrations not related to a resource

Basically I want to be able to run something similar to a custom_statements but outside any resource, probably in a custom type or repo level. To be more specific, I'm porting this type https://github.com/elixirmoney/money/blob/v1.12.2/lib/money/ecto/composite_type.ex into a Ash.Type. For that type to work, I need to run execute "CREATE TYPE public.money_with_currency AS (amount integer, currency varchar(3))" in a migration file to actually create the custom type inside postgres....

Atom fields will save upcase atoms as downcase

I noticed that if I add an attribute like this: ```elixir attribute :currency, :atom do allow_nil? false...

Using Ecto preload to load relationships in one query

Hello! Loving using Ash so far. I'm trying to make a simple Reddit clone, and I have a structure basically like this: - Post - belongs to an author (user) - belongs to a community...

pattern to use for embedded resources with variable fields?

I'm brainstorming how I'd be able to have embedded resources that have variable schemas, lets say I have a SocialMediaAccount resource, and I want an 'adapter_config' column that will be a set of config to integrate with the SocialMediaAccount, i.e: twitter api keys etc I'm going to implement an adapter pattern type thing that will include validations and a few methods to integrate with the social platform, I'm just wondering how I'd define that column in my resource? I was thinking of just using a map type - then handling validations etc in a custom change / validation?...

How to remove id as input option on create actions

My create actions for graphql are showing id as an option for input, is there a way to disable that? It breaks with the codegen library as it is sending id as an empty string

Allow writing values but not reading them back in graphql

I have sensitive fields that I want to allow setting in create/update but don't want them to be read back. I was able to make them return null with this
read :non_sensitive_info do
prepare build(deselect: [:cacertfile])
end
read :non_sensitive_info do
prepare build(deselect: [:cacertfile])
end
however I would like the schema to reflect those can't be selected, is there a way to do this? hide_fields also removes them from create/update...

Arbitrary queries, like Ecto.Query can do?

I'm using AshPostgres. I have requirements that require building a database query dynamically, based on data passed to it, and it involves SQL joins and possibly other SQL features. How can I do this with Ash? To start with, how do I do JOINs?...

Postgres Queries have wrong where clause

Recently we some read actions do not return the correct data, the Queries that are logged have an obviously wrong where clause
SELECT c0."id", c0."first_name", c0."last_name", c0."title", c0."legal_entity_name", c0."is_legal_entity" FROM "contact" AS c0 WHERE (false) []
SELECT c0."id", c0."first_name", c0."last_name", c0."title", c0."legal_entity_name", c0."is_legal_entity" FROM "contact" AS c0 WHERE (false) []
...

Use ash_authentication with Clerk

Hi! I've been trying to use Ash Authentication with Clerk (auth0 competitor: https://clerk.com/) and haven't been able to make it work. We're using the passwordless otp approach - based on the auth0 integration it seems like I should be able to do this using the oauth2 strategy. But I think validating the JWT requires a public key which the oauth2 strategy doesn't ask for. ...

How to manage belongs_to with phoenix form

Is there an example for how to manage belongs_to resource with phoenix form

Don't show existing value of form field

I have a sensitive value that I don't want displayed again, but I want an input to be able to update the value. Is there an option that exists for that?

What's the correct approach to update an actor inside an action

In my system, I have an Accounts.User resource that is normally sent to actions as the actor (this is also the resource used in AshAuthentication, etc). I also have another API called Payments and inside of it, it has a resource Payments.Customer. Both Accounts.User and Payments.User uses the same table, the just have some unique fields to it (mostly Accounts.User has info about authentication like password, email, etc, and Payments.User info about Stripe customer id, payments methods, etc)....

Authentication failures

I am trying to debug authentication failures in a multi-node setup (load balanced not Elixir multi-node). I get session data written: "user" => "user?id=6a6ece18-0ede-4b81-a22a-73edc43db6a8" implying the authentication was sucessful, but the failure callback is being invoked in the auth controller. I presume this may be related to the web socket possibly happening before the session data is recorded from the live session? Any pointers on how to debug welcome....

How to assign a default value to existing rows via Ash.postgres generated migration code

When a non-null column is added, is there a way to specify a default value to assign to the new column for existing records? I believe in Ecto, it's done something like this, but I'm curious if this can be done through Ash DSL.
add :new_field, :string, default: "default value"
add :new_field, :string, default: "default value"
...