Ash Elixir

AE

Ash Elixir

Join the community to ask questions about Ash Elixir and get answers from other members.

Join

support

showcase

today-i-learned

JSON-API Related() Seems Broken

Hi, 👋 there seems to be a regression in the JSON-API: It worked nicely (after you did a fix a couple of weeks ago), but after updating packages to the newest ones, I get an exception. Here’s the relation: ```...

custom step inside of map step in a flow.

It appears that the DSL is not setup to handle nested custom steps. When trying to use a custom step inside of a parent map step, I get a undefined function custom/3 (there is no such import) error.

How can I retrieve attributes from a resource record

Which is the preferred way to extract attributes from an Ash record? ```elixir record = App.Model |> Ash.Query.for_read(:last) |> App.read_one! ...

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?