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

How can I delete a record by id?

Currently I can destroy a ticket with:
Helpdesk.Api.destroy_support_ticket ticket
Helpdesk.Api.destroy_support_ticket ticket
...

How can we get a record by id?

I was able to figure out that i can get one with:
Helpdesk.Support.get! Helpdesk.Support.Ticket, ticket.id
Helpdesk.Support.get! Helpdesk.Support.Ticket, ticket.id
...

Example of setting a has_one relationship

I would appreciate an example of setting up a has_one relationship. I have the following resources: ```elixir...

Can a calculation use attributes of a related resource?

E.g., I have belongs_to :brand, App.Portfolio.Brand and...

Authentication actions as graphQL queries/mutations?

Is it possible to use AshGraphQL with AshAuthentication to sign_in and sign_up? I've tried adding the sign_in_with_password action as a graphql query: ```elixir graphql do...

How to use define_interface example in docs it's not clear

Show where you found the issue I have followed the Get Started guide to build the Helpdesk app and then followed the Whats next section where we have a link to learn how to use Code interfaces. While I perfectly understood how to use the define_for , because it builds on top of the Helpdesk app, I wasn't able to grasp how to use the define_interface, because the example for it doesn't build on top of the Helpdesk app....

Example of :create action with simultaneous assignment of relationship

Perhaps I'm too influenced by Django, but I've been trying to :create a new instance of a resource that belongs_to two other resource types by passing the other resources' .id values as parameters in the map, to no avail. Following the Getting Started guide, I understand how I first create the Ticket resource instance and a Representative resource instance and then use the :assign update action to assign the ticket to the representative. However, how would I go about creating a ticket with the representative already being assigned during the :create action? ...

Ash stopped working with ExMachina. Ash 2.5.10

Hello, I've been using Ash with ExMachina successfully up to this point. Recently I've wanted to upgrade Ash from 2.5.9 to 2.6.0, alongside AshPostgres from 1.3.3 to 1.3.8. I've tested combinations of different Ash and AshPostgres combinations to narrow down the issue. It appears to be caused by Ash 2.5.10. Specifically this commit https://github.com/ash-project/ash/commit/2787b5074b8b339057af6f0bc4ee3db5abf7c60d Our factory: ```elixir...

Which type for Text?

How long can a Ash.Type.String become with AshPostgres.DataLayer? 255 characters? What type would I use for longer texts? I found this list but didn't find a text entry: ```elixir :map -> Ash.Type.Map :term -> Ash.Type.Term...

Add Index to Attribute

I have this AshProstgres resource and would like to add an index to the link parameter. How can I do that? ```elixir attributes do uuid_primary_key :id...

Create a Unique Attribute

I have this AshPostgres resource and want to make sure the the title is unique. How can I do that? ```elixir attributes do uuid_primary_key :id...

"No changes detected, so no migrations or snapshots have been created."

Hi all. I am learning how to build a simple CRUD app with Ash, and for some reason mix ash_postgres.generate_migrations fails to pick up any migrations, even after I mix ash_postgres.drop and rm -f priv/repo/migrations/* to start from scratch. Any clues as to why?...

Create an Org on public schema and initial User on Org schema

I want to register an organization and an initial user at the same time. Creating an organizations automatically creates and apply migrations to the organization schema. The organization resource is global, so it's is saved on the public schema. The user should be saved on the organization schema. ...

In an action, how can I sort on a field in a relation?

I have an action performing a read operation with a specific relation loaded. That relation contains a position field that I wish to sort on first, then the primary id create_ts.
prepare build(load: [:status], sort: [:status.position, :create_ts])
prepare build(load: [:status], sort: [:status.position, :create_ts])
...

Best Way to Design Resources Properties

Hello. Firstly, this is a great community: friendly and responsive. Secondly, I have a question that, I hope, is not silly. Suppose I want to have a resource named Evals. In it, I want to have the attributes: description, and numeric, where each description corresponds to a specific numeric value. ...

module AshPostgres.DataLayer.CustomIndexes is not loaded and could not be found

I'm trying Ash Postgres tutorial and I've encountered this error. Maybe it's my mistake because I already have Phoenix in my project and I'm not starting from scratch. But I've never seen this error before even when I've tried to migrate existing Elixir app. I've got this error when I've tired to create migrations and run them. So I should have all my Postgres/Ash setup ready to roll. Base Ash without Postgres worked as expected. ```== Compilation error in file lib/app/support/resources/representative.ex == ** (CompileError) lib/app/support/resources/representative.ex:4: module AshPostgres.DataLayer.CustomIndexes is not loaded and could not be found. This may be happening because the module you are trying to load directly or indirectly depends on the current module (ash_postgres 1.3.8) expanding macro: AshPostgres.DataLayer.postgres/1...

Remove/Limit FilterInput and SortInput fields from a specific action in GraphQL

So, let's say I have custom fields that I added to my action to handle filtering and sorting, for example: ```elixir read :read do primary? true...
No description

Handle pagination on read action with GraphQL

In my read action, I have this line enabling pagination:
pagination offset?: true, countable: true, default_limit: 2, required?: true
pagination offset?: true, countable: true, default_limit: 2, required?: true
...
No description

Issues with sorting on `first` aggregate

```elixir actions do defaults [:create, :read, :update, :destroy] read :published do...

Limit visibility of fields with AshGraphQL

Sorry if this is a dumb question or something more related to GraphQL than to the Ash library itself.. But, is there any way to limt the visibility of some fields when running a graphql query to a resource? For example, let's say that I want to return a list of a resource, but I don't want to send the id because of some security concerns....