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.
JoinAsh 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.
JoinMultiple checkbox form
How to list calculation without raw queries
:full_url
. The calculation basically just concats the two with "://"
in between. If I want to get a list of full urls for all my resources, I learned I can do this MyResource |> Ash.Query.load(:full_url) |> Ash.list!(:full_url)
. But I can't figure out how to do this as an aggregate or an action. Is it possible? Is this the right way to do it? I think aggregates always require a relationship.Relying on metadata on "public" API an anti-pattern?
MyApp.Accounts.Session
resource that puts a token
in the metadata during the create
action since the token is hashed before inserting into the DB. The public API on the domain exposes it through an Accounts.create_session
action. Do we really want callers to be doing Resource.get_metadata
on the result in that public context to get the token
or is that an anti-pattern? Is there a better way to be surfacing that information? For example:
```elixir
def my_caller_func do
# ... other code...How to use field policies to show/hide fields in a UI?
%ForbiddenField{}
, Phoenix HTML doesn't know how to deal with it.
What's the best practice for doing this in the UI? The only thing I can think of is to use is_struct(resource.field, Ash.ForbiddenField
everywhere....How to load a nested relationship with a tenant?
ash read_one bug?
Ash.read_one(Submission, id: submission_id)
does not work
```...Single attribute join via belongs_to
Confirmation
AshAuthentication trusted audiences
trusted_audiences
to ensure that a user signs in from one of the tenants, but reject all others.
I have set it up as described in the docs, but when I test it locally by only allowing a "fake" audience in the list of trusted audiences, I'm still authorized to login. Do I have to do anything else to make this work, or have I misunderstood something?
```elixir...trusted_audiences
but struggles with using the /common/.well-known/openid-configuration
endpoint because it contains a placeholder {tenantid}
in its issuer which is not supported natively by assent. This cause the issuer validation to fail, because the issuer in my token contains my real tenant-id.
Could work, but requires a custom strategy?
2. Continue with using OAuth2 strategy. Works out of the box with multi-tenant applications, but needs to implement a custom trusted_audience
handler either as a change
function or in auth controller success callback (and then deny access unless audience matches allow-list)....where's the best place to run possibly long running queries on the DB after an insert / bulk insert?
ash_postgres.generate_migrations not working
mix ash.codegen remove_id_from_tokens
, it still insisted there is no change detected.
...:ash_domains
.
```
in config/config.exs
import Config
...AshAuthentication Testing
Unsupported expression in Elixir.AshPostgres.SqlImplementation query: `datetime_add`
OrgSubscription
is a many_to_many
resource that connects Organization
to SubscriptionPlan
.
```elixir...No such input for atomic_update
Using no attributes to use a parent_type / parent_id style table as a join table
How to model this runtime config in Ash?
(true)
. This means that only one row is allowed in the table. The table itself just has one column which is a JSONB type. When the app starts up it reads this config and saves it with Application.put_env
. Then in various places in the app I just fetch the config from the application env and pattern match out what I need. I could probably use persistent_term, but it's not a big struct. When a change is made to this config struct I update the database row and use Oban.Notifier
to broadcast a message to all other instances of my app to tell them to refresh their application env cache of the config.
What would be the Ash way to implement this? It doesn't have to work exactly like this. This is the best I came up with, but I'm happy to hear alternatives 🙂...Test initialization takes more time than expected
time mix test
. Elixir's test runner says it takes 0.5 seconds to run all tests, so something happens before the test runner starts. Right now my hypothesis is that `Getting extensions in cu..."ERROR 42704 (undefined_object) type "vector" does not exist" during migration.
Post
resource:
1. First, created setup_vectorization.ex
in folder lib
...Is there any public function to prettify a BulkResult/Change error?
:string
error message but in this case there is none, i think AshJsonApi translates this errors to a message somehow, is that function public?
```elixir
%Ash.BulkResult{
status: :partial_success,...AshJsonApi.Error.to_json_api_errors(Domain, Resource, error, :create)
ManualRead for wrapping an API using attribute constraints
""
, which I'd prefer to be nil. Pretty sure this can be handled with constraints on attributes when the values are casted.
The example in the docs shows manually creating the resource's struct from the API response and using Ash.Query.apply_to/2-3
. Will this approach apply the constraints for the returned values doing this? Or is there a better way to make sure the constraints are applied?...