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

Igniter `Proceed with changes` message when there is no changes

Hi, as you see this is my simple code for igniter, i am using update_file function, because before it i have a function that ensure_package_json_exists. I do not know why it shows me even there is not changes Proceed with changes? It is is my bug? I tried to use create_or_update_file function, but if file exist and there is not anything to change, it still shows Proceed with changes? ...
Solution:
I think the latest version of igniter may have a fix for this?
No description

livebook

Has anyone ever created some Ash resources and tried to use (ie create and interact with) them in a LiveBook without publishing code to Hex or a private repository? I'm in the middle of trying. The concept: use Livebook instead of iex. I know, crazy.
Solution:
The problem with the excellent educational livebook for my case is that I'm not learning Ash -- I want something better than IEx to interact with my code (which depends on Ash and a ton of other functionality), like a library. I am not just asking the universe for a solution. I have a solution for my app, and it's pretty bad. I will document this and I'm closing this issue. Anyone who stumbles on this post should be aware that they should not attempt.

createdby / updatedby

When ash_authentication is in use, do you recommend adding created_by and updated_by references for other resources to the user resource.. or is this a dumb thing to do?
Solution:
It depends entirely on the situation 🤷‍♂️

How to create a negative test for a verifier

Hi, I'm working on adding some verifiers to the transformer for the Ash Neo4j DataLayer, and I've got a simple Verifier that checks neo4j convention on the resource label Here is the verifier: ```elixir...
Solution:
Define the module inside the test block

Add custom key in a action or other macro without changing the core of Ash

Hi, i am creating a dashboard lib, that support multi ACL, so i want to ask i can add a custom key inside action without changing Ash core? and access it for my dashboard? it is not just user role access for example another options like where this action should be shown or the icon of it and etc Or i am forced to create my own macro?! out of action or etc! (this is very dirty way) Thank you...

Using Ash.Query in Ash.Query.load

After updating ash from 3.4.62 to 3.5.12 the following code causes an error. How do I fix this? Error.Unknown.UnknownError{ error: "** (BadMapError) expected a map, got: nil", field: nil, value: nil,...

Pubsub isolation in tests

I have a Phoenix application which has LiveView tests. When i run the tests in async mode the broadcasts from one test can interfere with other tests. What is the best way to handle this? Scenario: * Test 1 opens a live connection to a live_view which listens to broadcasts on a Ash resource...

Policies: authorize if user is an admin of the requested resource's organization

I have a group resource with these relationships: ``` belongs_to :educator, User do source_attribute :educator_id destination_attribute :id...

Read actions

I have this read action: ``` read :groups_by_organization_id do argument :organization_id, :uuid, allow_nil?: false ...

enabling multi tenant for graphql

turning on graphql for first time in my app (multi tenant) ```elixir router.ex import AshAuthentication.Plug.Helpers...

AshOban job failures

I have a job that runs using AshOban, which I find a very nice way of doing things tbh, as most things you've done so far! However it seems to me that the only way to handle failures is to give it an action to run. For example setting the state to failed, however I'd like to be able to see the failure in Oban apart from setting the Resource as failed. I have scoured the documentation but I don't see a way of having the Oban job fail on failure. Am I missing something? Was there a specific reason this is like this?...

How to use datetime_add in set_attribute?

Hi guys, a quick question, maybe I'm doing something stupid... I want to increase trial_ends_at by 7 days in an action. I thought ```...

Writing a Change with DB lock

I have a change that do some db queries in order to verify that the value being inserted in a foreign key is valid. Since I'm being based on other records to validate this field I need to lock those to prevent them to be modified in the middle of the change. Before adding any locking to my change I decided to test this concurrent scenario so first I make it fail so then I could be certain the problem is solved once I lock the records. My current issue is that the tests mean to run concurrently are not failing. No mater how many times I run the tests, the records are being updated in order as if a locking mechanism were in place...

Slow pages ... due to too many load of data...

Hi Community, In a platform I am currently developing, some pages are slow. Too many load of data... I am wondering if there is a config option that permit to have in the log the files/component/lines that call the ash.load or Ash.get... which do the SQL access to the DB ? In order to analyze the issue quicker ?...

Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"

Protocol.UndefinedError at GET /profile protocol Phoenix.HTML.Safe not implemented for type AshPhoenix.Form (a struct) Got value: ...

Working with Transactions

Hello! I'm working on converting the following Elixir/Ecto function into an Ash action: ```elixir def create_team(attrs, user_id) do...
Solution:
```elixir change fn changeset, context -> Ash.Changeset.after_action(changeset, fn changeset, team -> team_member_attrs = %{ # actor is in the context...

How to ergonomically add/remove to an array of embedded resource in graphql

The docs state flatly that if you do updates on an array'd embedded resource it simply calls destroy on them all, and then recreates them. This makes sens as you typically atomically replace the json blurb on read/write. I have to model this as embedded as I am sharing the table with a legacy system in a transition period, or I would just model it as actual rows and use manage_relationship. Right now I am looking for the most ergonomic way to have addFoo and removeFoo mutations in my parent resource....

Using manage_relationship with bulk_create

I'm having trouble using manage_relationship with a bulk create. I want to be able to create a bunch of "child" resources in one request while also providing attributes to create their "parent" resources at the same time. In a normal create request, I can create a child and parent at the same time, but in a bulk create, it seems like it's trying to insert the parent resource twice. Child resource: ``` actions do...

Ash.Type.Tuple Enumerable not implemented

I have an attribute of type :tuple defined like this: ```elixir attribute :model, :tuple do constraints [...

Correct Way to Display Spark.Error.DslError?

Hi! I’m writing a custom DSL extension and I’m struggling with making Spark.Error.DslError show up in the right place. I followed patterns from core Ash code (like default_accept.ex and verify_identities.ex), and also looked at extensions like Ash Cloak. Here's what I did in my verifier: ```elixir...