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

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

Filter fields to be returned on an Ash.Query and an AshJsonApi route

I'm having a hard time finding out how can I filter returned fields from an Ash.Query this is my code: ```elixir read :quantities do description "Product Quantities available in MMS"...

Virtual attributes

I have several manual relationships that are populated using recursive queries, and I would like to be able to expose the depth and path fetched by those queries on the related resource. When not in the context of the relationship, these attributes don't make sense, and thus needn't be queried nor have columns in the table. Is there a way to create "placeholder" attributes that will be valid in the resource struct, for purposes of manual population? Right now, I'm putting them in __metadata__, which hopefully is safe....

Registry splitting with AshGraphql and AshJsonApi

Taking a crack at splitting my registries. I'm getting a lot of this: ``` In field Author, :Author is not defined in your schema. Types must exist if referenced....

Additional attributes on join table for many-to-many relationship

I have an app that has courses and teachers. The relationship is many to many since each course can have many teachers and each teacher can have many courses. In the join table/resource I have an additional attribute called role (one can be primary or extra teacher for a course). I managed to connect the resources so that I can create a new relationship by calling: TheSchoolApp.Courses.Teacher.update(teacher, %{courses: [%{id: course.id, role: "primary"}]}) The problem is that it doesn't fill in the role attribute. It just leaves it as nil. ...

Is there a policy bypass for manipulating resources from iex?

Didn't see anything about this already posted. Or should I be identifying as an actor from iex somehow?

Ash Phoenix Form potential bug

Hey ```elixir AshPhoenix.Form.validate(socket.assigns.form, params) |> AshPhoenix.Form.submit()...

Better way to do this query?

I have a simple search action for an autocomplete, and I want to have it skip the filter if the search term is "" in order to just return the top sorted options. I have a pretty simple solution, but was wondering if there's a cleaner/more idiomatic way of doing it: ```elixir read :autocomplete do argument :search, :ci_string ...

AshPhoenix potential bug with relationships

I have the following form: ```elixir <.simple_form :let={f}...

AshAuthentication redirecting on errors

I'm using AshAuthentication with the email and password strategy. When I enter incorrect info, whether that's a wrong password or for a nonexistent user, I get redirected to another page with the error. Is this intentional design or have I configured something incorrectly? I was expecting to get errors in the (to me) "normal" form validation red text sort of way. Didn't see anything about this in the documentation, just curious if anyone else has experienced this. Thanks so much :thinkies: 🙇