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

Multitenancy `global?` authorization question

https://hexdocs.pm/ash/multitenancy.html#attribute-multitenancy
If you want to enable running queries without a tenant as well as queries with a tenant, the global? option supports this. You will likely need to incorporate this ability into any authorization rules though, to ensure that users from one tenant can't access other tenant's data.
Could you please provide a brief example of what incorporating this into authorization rules would look like?...

Trouble with setting up Ash.Authentication

I am getting the following compile error and have no clue what it means. "Module" does not appear in my files. I have attempted to follow the various guides to setup google to use OAuth2. (EXIT from #PID<0.95.0>) an exception was raised: (Spark.Error.DslError) [nil] authentication -> api:...

Compile Error with JsonApi using related()

Hi there! 👋 I’m getting error message "(ArgumentError) Found an action of type read while looking for an action of type get_related, Perhaps you passed a changeset with the incorrect action type into your Api?" and I don’t understand how to solve it. Here’s the code: ```...

Query

how do i translate this code for example Helpdesk.Support.Ticket|> Ash.Query.filter(contains(subject, "2")) into the resource's read action. Basically as part of my read action I want to filter with something similar to SQL like. i can do it on iex. but not sure how to intergrate into read action for my api.? i want to know how to use the contains(subject, "2") inside the read action?

Ecto.Multi Usage

I saw only one post about how to use Ecto.Multi it directed me to Ash.Flow what I didn't find an example usage. For context I have a record I want fetch using token provided its valid, after I get the record successfully I want to update a field on it and finally on success issue a JWT or on error just return the error. How will this look like in the update function ?. Is this a candidate for to consider using ManualActions ?...

Skip Migration for a Resource

Question: How do I skip generation of migration for a particular resource? Context, I have an existing ongoing project that I want to port over to STAPLE. The project 1. has existing tables and data in production. The migrations are separately maintained using LIquibase...

`Spark.Dsl.Fragment` validations

It seems that when using Spark.Dsl.Fragment, there are some validations that are happening on the fragment which would be preferable to have happen on the complete resource. A couple examples: If I define my code_interface section in a separate file from the actions themselves, the validation fails something like:...

Date time

say i want to create a resource via json api post request that has an attribute of type :utc_datetime_usec, since the value is received as a string how can i convert the string to DateTime inside the create action of the resource, i assumed there is auto cast, however it seem to not work?

add ilike filter to graphql queries

Is it possible to extend the generated filter options in AshGraphql by e.g. an ilike filter?

ResourceValidations error

I just updated a bunch of deps and something that worked fine before just doesn't right now. I have the following error: ``` ** (EXIT from #PID<0.104.0>) an exception was raised:...

authorize_url for Google oauth

Hi @jart I was able to get github oauth to work following the getting started with Github guide, and now trying to get google oauth to work using oauth2. The doc's example for the authorize_url value is this.
authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
authorize_url fn _, _ -> {:ok, "https://exampe.com/authorize"} end
If the path 'authorize' should be added to the router, I'm not sure what kind of module it should point to. Can you give me some pointers?...

Using ex_money_sql with Ash

I'm hoping to use the Money type defined in the ex_money library as an attribute in Ash resources. This library has a companion, ex_money_sql that creates a Postgres migration and creates a custom type: ``` def up do execute("CREATE TYPE public.money_with_currency AS (currency_code varchar, amount numeric);") end...

SQLite support

Not sure if this is the right place to post this but I still wanted to open the discussion. From what I understand, a ash_sqlite lib is in the plans although it's not known yet when it will be available. If you're looking for help on this one, I'd love to help out for the implementation. In the meantime, what is the suggested approach to use SQLite without too much hassle? Thanks 🙂

Many to Many Error

Given these relationships: ```elixir Capability relationships do...

Manage relationship argument question

I do not see an argument type for changes when providing a list of target IDs and I want manage_relationship to just add/remove relationships between existing resources (many-to-many). I will try map with just id populated, but that seems redundant.

How to read resource without actions

I'm trying to inspect MyApp.Accounts.Token using iex, but I'm getting NoPrimaryAction error. Is it possible to inspect resources without defining read action? Is there a way to convert it to Ecto.Schema, so I can use Ecto.Query? ...

Json Api

Say I have two resources user and profile. relationship being profile belongs to user. when iam returning user resource how can i return it along with the profile as response from get request?. i have a read action that works well and return data as expected via iex. however if i use the same action on json api, i only recieve user data without profile data. can someone guide me?

Association not working. Is 'property' a reserved name?

I am trying to associate one resource with another. This works well for most resources I have. However there's this one resource called 'Property' that I can' get to associate with any other resource. If you see this code after submitting a form: ```form #=> #AshPhoenix.Form<...

graphql

So I have thumbnail images stored as binaries that I want to expose via graphql as base 64 encoded strings. I have set a default read action with prepare build(load: [:thumbnail_raw, :thumbnail]) where thumbnail_raw is the binary field in the db and thumbnail is a calculated field. I also define the load callback in the calculation to ensure :thumbnail_raw is loaded before the encoding happens in the body of the calc - i.e. there are two places where I force :thumbnail_raw to be loaded. The calc works fine everywhere else, but returns nil when access via graphql. I have IO.inspected the records sent to the calculation and the key I have asked to be loaded isn't loaded. Versions are a little behind, but I've checked the commit logs for changes in these areas and can't see anything: ``` {:ash, "~> 2.4.0"},...

Use of managed_relationship not clear

I am trying to create an action that will create a Supplier and populate the 2 belongs_to relationships it has. I have tried a default create action with the id fields populated, but they do not get set. I have tried manage_relationship with both ids as action arguments and with records as arguments.
The most recent attempt: create :new do argument :company, :uuid do...