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 generated mutations are bypassing schema middleware

I have this middleware in my GraphQL schema to check if the user is authenticated: ```elixir def middleware(middleware, field, obj) do if obj.identifier in [:query, :subscription, :mutation] and...

Assumption failed: Action does not correlate with an authentication strategy

Follow up question related to https://github.com/ash-project/ash/issues/516 The same error persists after adding change set_context(%{strategy_name: :password}) ``` update :change_user_timezone do argument :user_timezone, :string do...

How to define a read method for preloading associations inside a resource?

Apologies for the noob question, but I couldn't find it in the docs. Let's say I have an author resource that has_many posts. How do I use the read DSL to get an author by its ID and preload its associated posts?

One way `has_many` relationships

Are you able to have a has_many relationship where it's just one way? I.e. I have a User resource which can have many List resources but I don't every really care about List resources knowing which users it belongs to

How to represent an embedded schema in AshGraphql

I have an existing Ecto schema that has an embedded_field, which itself is backed by an Ecto schema. How do I use the attributes DSL to expose this field in my AshGraphql query? Here's the field in Ecto: embeds_one :details, Details I tried this in the Ash attributes: attribute :details, :map, but the GraphQL response had this error: Field "details" must not have a selection since type "JsonString" has no subfields....

AshPostgres compilation error

While compiling ash_postgres 1.3.14 I get the following error and don't really know wether it's something related with my codebase or it is a library error. ``` $ mix deps.compile ash_postgres ==> ash_postgres...

no data in Ash.DataLayer.Simple

I have this action in one of my resources ```elixir read :read do argument :ref, :string do...

new ash_graphql version generates duplicate enums

I tried upgrading today from ash_graphql fbebb21d1867acf9d43ad09c56374ad98ea8594f to fbebb21d1867acf9d43ad09c56374ad98ea8594f (also latest commits on other ash libraries) and I was unable to compile. I debugged a bit and was able to locate the problem here https://github.com/ash-project/ash_graphql/blob/0ecf70b54b78c6caa75d706ab4deacb214a3ee51/lib/resource/resource.ex#L2341 AshGraphql.all_attributes_and_arguments() returns all fields including the fields of embedded types. ...

query filter with fragment issues

HI I am trying to do the following ```...

How can I add fields to the default AshAuthentication signup form?

I see which modules are being called but I don't know how to add new fields to registration (first name, last name, cell #, etc.). Are there docs for this and I just missed them?

Insert into Database without Form

Is there a way to insert into the database a new entry without a form. i.e. a user does a form action which creates an entity and then I need to update the user to attach them to that new entity....

%Ash.Error.Changes.Required{

Another newbie question.. AshPhoenix.Form.submit is failing with this error message. Below are the related codes. The issue seems to be due to the fact that the new email address is not added to arguments. <error message> iex(16)> [debug] HANDLE EVENT...

Authentication with AshGraphQL for specific queries/mutations

Maybe I'm missing something, but I'm sure what is the correct approach to check and halt a GraphQL query/mutation inside AshGraphQL. Right now I already have access to my actor, but there is no verification if the actor is really there or if it is nil. What I thought about doing is just add a policy to check if the actor is nil or not to the queries/mutations that need to be logged, but I'm not sure if that is the right approach or if there is a better/correct way....

Only change a few fields `ON CONFLICT` in an Upsert

Let's say I am implementing GitHub login myself. I have a User resource with a few attributes, and its create action is an upsert. Its working and Ash generates the right query, however, I want Ash to not include a few fields in the ON CONFLICT part. This is the query Ash generates: ```sql...

Concat with nil values

The built in concat calculation returns nil when any of the values it is concating is nil. I need a nil friendly concat and I could use something like this (which only works on the data layer and is postgres specific): ```elixir calculate :full_name, :string,...

Manually adding argument to action in form before calling AshPhoenix.Form.submit

I'm using AshPhoenix.Form to handle creation of a resource in LIveView. In my resource, I added this action: ```elixir...

custom statement constraint

Hi How do I check for the constraint defined in the custom statement. Like the one defined here https://discord.com/channels/711271361523351632/1071850815872040961/1071883244410253433 Any suggestions and tips would be great. Thanks for your help. ...

(CaseClauseError) no case clause matching: #Ash.Changeset<api

This must be a very basic question but I'm getting the above error in running this code. add_user_timezone is defined in user.ex which is listed in MyApp.Accounts.Registry. What am I missing? ``` current_user |> Ash.Changeset.for_update(:add_user_timezone, %{...

How to filter results when using keyset pagination?

After a lot of trial and error, I managed to get the next page for the keyset pagination in my project by using something like ```elixir next_page = MyApp.ResourceApi.page( socket.assigns.items, :next...

How to get rid of ellipsis and see everything in IO.inspect()

When we look at the examples there are lines with only '...' that replace some data, see https://www.ash-hq.org/docs/guides/ash/latest/tutorials/get-started#try-our-first-resource-out The truncation seems some behaviour of IO.inspect(). I would like to use IO.inspect() and see everything, even it uses a lot of space. I tried the following code in an exs script with Elixir 1.14.1 (compiled with Erlang/OTP 25) :...