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

Expected at most one result but got ...

I'm not sure if I've encountered a bug or not. I have the following action: ```elixir read :get do...

CRDT and Ash

First of all: Why use Ash? Because declarative programming and Elixir are awesome. Why CRDT? Because they are awesome too - anyone who's dealt with LiveViews losing their sockets knows what I mean. I'm using Rustler to talk to a Yjs (the package is Rjs which is pronounced 'wires'). A NIF written in Rust accepts an Ash resource instance and creates a Yjs document from it. I am contemplating how to do this in a generic way, and it appears that, while I might be able to code an Ash extension for this, it won't work with Rust serde. I'm contemplating using Json instead since it works bidirectionally between Ash and Yrs. Are there any gotchas I should be aware of when serializing Ash structs to Json? Would at least parts of JsonApi be of help? I haven't thought a lot about references yet but I think they will be links instead of being embedded. Every resource will have its own Yrs document. For now, this is just a fun experiment for learning CRDT and Rustler. Thanks!...

How to return custom errors in a after_transaction call?

Let's say I have a change with the following implementation: ```elixir def change(changeset, _opts, _context), do: Ash.Changeset.after_transaction(changeset, &do_change/2)...

How to use relationship id in a `get_by` read action

My resource has this relationship: ```elixir belongs_to :customer, Customer do allow_nil? true...

relationship required

Hey! Whats the best way to fix this error? ``` %Ash.Error.Changes.Required{ field: :account, type: :relationship,...

Action argument shows up as JsonString in graphql schema

I have this argument referencing another resource
argument :credentials, {:array, Credential}
change manage_relationship(:credentials, type: :direct_control)
argument :credentials, {:array, Credential}
change manage_relationship(:credentials, type: :direct_control)
however this argument is not showing the inputs that are available, is there a specific way to configure this so the input shows up correct in the schema?...

many_to_many with non-default attribute not preloading...

So, I have a many to many relationship I'm strugling with. It must be something silly, but I just can't make it work. I have a resource called Game, which is actually for a table called assets, so in the join table one of the attributes is asset_id and not game_id. The join table is called playlist_entries...

Looking for an example of an attribute-based custom filter check I once saw in an error message.

I saw once it in an error message, but can't find it anywhere online. It would correspond to this passage in the documentation, for create actions:
Keep in mind that, for create actions, many expr/1 checks won’t make sense, and may return false when you wouldn’t expect. Expression (and other filter) policies apply to “a synthesized result” of applying the action, so related values won’t be available. For this reason, you may end up wanting to use other checks that are built for working against changesets, or only simple attribute-based filter checks. Custom checks may also be warranted here.
Keep in mind that, for create actions, many expr/1 checks won’t make sense, and may return false when you wouldn’t expect. Expression (and other filter) policies apply to “a synthesized result” of applying the action, so related values won’t be available. For this reason, you may end up wanting to use other checks that are built for working against changesets, or only simple attribute-based filter checks. Custom checks may also be warranted here.
...

Hooking `manage_relationship`

Is there a way to specifically hook into manage_relationship, e.g. for an extension? I'm looking to get notified any time a relationship is added or removed.

Composing filter expressions

I'm trying to figure out how to reuse/compose (eg. apply a not) a complex expression that I use in filters. I have a complex filter expression that looks like this: ```elixir read :get_processed_for_visit do...

AshAuthentication error when trying to use password hashing change in seed action

I'm trying to use this action to seed some test accounts: ``` create :seed do accept [ :email,...

Can't use `actor` on aggregates

Hi - I'm trying to use ^actor on aggregates but it's throwing an error. This is my aggregate: ```elixir aggregates do first :max_index, :audio_files, :index do...

adding for update to a read action

I have an after_action block that performs a select using a read action. I'd like to turn that select into a "SELECT FOR UPDATE" - is that possible?

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....