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

AshGraphql: Updating a managed has_many relationship

I'm getting "In field \"id\": Unknown field." in the GraphQL response error. It's referring to the id provided in the has_many related record . ```elixir This is the updateWebSite input argument. It's a UpdateWebSiteInput type. input = %{...

AshGraphql Manage Relationships with multiple actions

Hello, I'm using the AshGraphql managed_relationships DSL to allow a GraphQL mutation to update relationship data on a resource. I works fine with the :create action, but on adding the similar code for the :update action, it gives errors. Here are the relevant parts of the resource module: ```elixir defmodule GF.WebSite do...

Adding custom routes with AshJsonApi

Is it possible to add custom routes like: ```elixir json_api do type "many_actions" routes do...

Getting the user's IP address in an action

Is there a cross-interface (GQL, JSON, etc.) way to get the user's IP address in an action?

Multitenancy and no_attributes? relationship option

Reading through the docs, I encountered the part about the no_attributes? option while declaring relationships.
Specifically, if you have a tenant resource like Organization , you can use no_attributes? to do things like has_many :employees, Employee, no_attributes?: true , which lets you avoid having an unnecessary organization_id field on Employee
Specifically, if you have a tenant resource like Organization , you can use no_attributes? to do things like has_many :employees, Employee, no_attributes?: true , which lets you avoid having an unnecessary organization_id field on Employee
...

AshPhoenix Form use for `many_to_many` relationships through `append_and_remove` management

Hi all, and thanks for this amazing project! Today I'm trying to figure out how to use AshPhoenix.Form with field of type {:array, :uuid}, for example in the context of managing a many_to_many relationships through append_and_remove, in extension of your example here https://hexdocs.pm/ash/2.6.18/managing-relationships.html. For example, I have this resources with the desired result of allowing the user to select a list of tags from a multiple select:...

Pagination required by default in ash_graphql?

Hi, I've just upgraded to a new version of ash_graphql and now I'm getting errors of the form: ``` ** (Ash.Error.Invalid.PageRequiresPagination) Pagination is not enabled on resource MyResource for the action %Ash.Resource.Actions.Read{name: :my_action, pagination: false, primary?: false, filter: some_attribute == true, description: nil, get?: false, manual: nil, modify_query: nil, transaction?: false, arguments: [%Ash.Resource.Actions.Argument{allow_nil?: true, type: Ash.Type.Integer, name: :limit, default: 1, private?: false, sensitive?: false, description: nil, constraints: [min: 1]}], preparations: [%Ash.Resource.Preparation{preparation: {Ash.Resource.Preparation.Build, [options: [limit: {:_arg, :limit}, sort: [order_by_attribute: :asc]]]}}], touches_resources: [], metadata: [], type: :read}. Check that you've enabled pagination in your action. For example:...

Calculate aggregations?

I want to sum_1 = sum_some_data(user_1, :column_1), sum_2 = sum_some_data(user_1, :column_2) then sum_1 - sum_2 and return this value.

Postgres Table(s)

I have a user resource and I need to assign a user to one_on_one resource. The one_on_one resource has two arguments user_1 and user_2. I am at a loss on how I should define the relationship. I know how I want the table design to be: Where user_id_1 can't be the same as user_id_2. Anyone else struggle with this part of Ecto? ``` user:...

** (KeyError) key :options not found: Error on AshPhoenix.Form submit

This is my form ``` <.simple_form for={@form} id="todo-form"...

Using AshGraphql to fetch a single item without providing arguments

My app uses attribute-based multitenancy. There is a resource called WebSite, and the tenant would normally have only one of these. I am trying to create a GraphQL query called getWebSite that returns the tenant's WebSite, but the query response has the error, "In argument "id": Expected type "ID!", found null." I don't want the query to take any arguments. Here is the test that reproduces there error: ```elixir...

function WequalWeb.AshAdmin.PageLive.__live__/0 is undefined

Hello! I'm trying to setup AshAdmin but I'm getting this error when I try to open the /admin route. Any idea on what could be going on? Thanks!...

How to manage relationships with AshGraphql

I have a Resource called WebSite that has_many :components, and each is a WebComponent. This test failed: ```elixir test "success creating a WebSite", ctx do input = %{...

key :current_user not found error in ash_authentication_phoenix tutorial sample home.html.heex

Hello, I have progressed with implementing https://ash-hq.org/docs/guides/ash_authentication_phoenix/latest/getting-started-with-ash-authentication-phoenix but unfortunately I get a key :current_user not found error when starting the server as in https://ash-hq.org/docs/guides/ash_authentication_phoenix/latest/getting-started-with-ash-authentication-phoenix#start-phoenix I have double checked the generated routes, the contents of the AuthController and the associated auth_html.ex and failure.html.heex. I can create a new user through localhost:4000/sign-in but then after I still get the same error. It seems the current_user simply does not get assigned. How can I debug this?...

Set tenant within read action in resource dsl?

Hi, is it possible to set the tenant within a read action in the Resource DSL? I tried to call set_tenant/1 in there but it doesn't seem to work......

I'm trying to understand how to use attribute-based multitenancy with AshGraphql

1. The documentation says to set up a multitenancy block in your resource module, and add a strategy and attribute. Check: ```elixir multitenancy do strategy :attribute attribute :org_id...

AshGraphql :create mutation returns empty result

I wrote a test for a GraphQL query that was passing, and the response has a nil result object. Details to follow......

How to replace Ecto.Schema modifications?

So I have my custom ULID implementation. It takes UUID format as well as BASE64 url encoded and transforms it to UUID in database layer. When taking out of DB it's transformed to BASE64 again. It creates shorter URLs which is nice. With ecto I needed just 2 lines of code to have all database IDs in this format. But I don't know what's the best way to do it in ash. Also I've modified timestamps to be utc_datetime_usec instead of naive datetime ones. It's easier to convert them to different timezones that way. Here's the code:...

How to solve "(Jason.DecodeError)" in Ash Authentication Phoenix tutorial

Hi everyone, I am going through the Ash Authentication Tutorial but I'm stuck on an obtuse error that gives me few clues where to debug it: ``` my command $ mix ash_postgres.generate_migrations --name add_user_and_token...

`AshJsonApi` composite primary key

Would like to add AshJsonApi to a project currently using AshGraphql, getting complaints about my many_to_many resources:
json_api -> primary_key:
AshJsonApi requires primary key when a resource has a composite key
json_api -> primary_key:
AshJsonApi requires primary key when a resource has a composite key
...