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

Ash+Phoenix+Authentication Starter

I went through “Getting Started Ash Authentication Phoenix” yesterday, but if I want the “forgot password” flow, it looks like we should instead copy the dev subdirectory in the ash_authentication_phoenix repo and rename modules and directories. Is that the recommended way?

Kicking off an Oban job in the same transaction as an action

What's the right way to kick off an oban job in the same transaction as for example creating an ash?

Porting `cloak`-managed fields from Ecto schema to Ash

One of the Ecto schemas in my project uses Cloak to encrypt a value to a column on write, then decrypt the column on read and expose that on a virtual field on the schema. For example, the schema has these two fields: ```...

Resources without primary key not supported

I have this code: ```elixir defmodule Scribble.EmailHandler.User do use Ash.Resource use Ash.Resource, data_layer: Ash.DataLayer.Ets...

Lookups/calcultions based on has_many relationships

I will try to be very precise and concise, so apologies if this comes off rude-ish. - The history table contains a long list of entires that a user enters the application. Imagine like a list of chat entries. - The users can bookmark any number of those history entries - when retrieving a list of entries (e.g., last 40 entries, or all entries in a paged manner) I would like to try and in one go retrieve both the entries and whether they were bookmarked by this particular user...

`:ci_string` not becoming `citext` with `Ash.Type.NewType`

In my migrations:
add :email, :text, null: false
add :email, :text, null: false
I've solved this with casing: :lower for the example above, but there are fields where I'd like to preserve casing....

Bidirectional `manage_relationship`

Is there a way to get manage_relationship to manage the other side of the relationship simultaneously? Specifying destination_relationship: :other etc.

cannot use pin operator ^agg_authorize?

Hey guys, going through the tutorial but am getting the error above when compiling. im on ash 2.6.29

Conditional filters in read actions

Hi there, I'm back with another quesion that i couldnt find an answer to - sorry if i missed something. I have a resource with a list of form submissions, where i have a read action to get all form submission of a specific form id, with the form_id as an argument. that works fine. Now i also want to add the possibility to get all records submitted after a specific date, which also works this way: filter expr(submission_time >= ^arg(:min_submission_time))....

Loading nested resource encrypted fields crashes ash_postgres

I have these resources: ```elixir defmodule Marketplace.Markets.Property.Offer do ......

Policies that reference other policies

Often I find myself wanting to say, "Allow this if that is allowed on X". In the context of owned resources, it may be sufficient to take action on the subresources via the parent. Many times though, the actions that need to be taken are complex enough that it makes more sense to provide actions directly on the related resource, and often enough there is not an implied ownership of the resource at all. Is there a way to write a policy that somehow depends on another policy for a seperate resource?...

Polymorphic resources

I have a number of resources that I'm beginning to add things like comments, attachments to, and would be interested what the idiomatic way to do this is. For this case, I can see a macro or something like https://discord.com/channels/711271361523351632/1079057460700123186/1092860018862346300 working as a template, specifying a different resource name and table for each instance....

How to test LiveView behind AshAuthentication?

I have some LiveViews that require an authenticated user to access (AshAuthentication). How do I simulate login for the user? I saw that there are a few tests in the AshHQ repo and I did try to copy all of the relevant stuff, but I still can't get it to work. Here's what I have so far: ```elixir...

Best way to process a field in a form changeset before validation

In my form, I have a price field which uses a JS hook to format it in a nicer way to the user. For example, if the user types 23432, it will display in the input element 23,432.00 The problem that I'm having is that if I send that value to be validated with AshPhoenix.Form.validate, it will fail since 23,432.00 is not a valid decimal, so what I do is run this in the params before the validation:...

Nested flows steps possibly returns differently if using `apply` ?

Sorry if I bother you again on flow issues. This step: ```elixir def run(input, _opts, _context) do Logger.info("Creating resource #{input.resource}") ...

How to have smaller pubsub payloads?

So, AFAIK when using the built-in pubsub feature of Ash, the payload will always be the action returned data with some other stuff. That payload sometimes is very big, especially if it is a big resource and there is a bunch of processes subscribed to that event. This is OK if you need the full resource, but sometimes you don't need the whole thing. For example, let's say I have a front page that lists properties and I subscribe to an event that will notify me when a new property is added. In this scenario, I don't want to get the full property and just add to the list, what I want is just add a button to the page saying "there are new properties available, click here to update your list"....

How to handle other resource notifications when inside a change?

Here is my change implementation: ```elixir defmodule Marketplace.Markets.Property.Offer.Actions.AcceptOffer.Changes.ChangePropertyToPending do @moduledoc false...

`Ash.Type.NewType` defines multiple GraphQL types with the same name.

I have the following custom type ```elixir defmodule MyApp.Types.DayOfWeek do @moduledoc false ...

Map type with specific field/values

Hi, lately I've been creating more Graphql Mutations and I'm really missing a good way to type the arguments. I tried using embedded resources as types and that gave me nicely typed inputs but it did not work correctly as the underlying datastructure is a struct and all fields are always present, which lead to fields which were not being sent in the mutation being overwritten with nil. Is there a way to create typed maps right now?...

Ash-hq default theme showing wrong colors

I've got dark mode on macOS and it looks like Ash-hq is getting a bit confused with the default theme. Explicitly setting the theme to dark mode seems to fix it.
No description