Robert Graff
AEAsh Elixir
•Created by Robert Graff on 8/18/2023 in #support
Duplicate input types for GraphQL
Given a resource like this
I get multiple errors about duplicate related to Option (UnionType) and its children (OptionString, OptionBoolean).
If I comment out the update mutation, it generates all the types as expected for the create. The update mutation should not require any additional type or input types.
11 replies
AEAsh Elixir
•Created by Robert Graff on 8/11/2023 in #support
Applying constraints to embedded union types
I have a resource when an embedded array of union types:
When doing a create or update on the parent (MyApi.Package) with an option that has an invalid key (see constraint), it's not returning
%Ash.Error.Invalid{}
as expected. I've tried applying a validation in lieu of an attribute constraint, but the validation is never called.
Additionally, the identity is not enforced.22 replies
AEAsh Elixir
•Created by Robert Graff on 8/3/2023 in #support
Why don't read actions filter by attributes?
Given a read action
There are no arguments for the action, so the following does not select on
email
.
I would assume any filterable attributes would be automatically applied as a filter. You could also have an accepts
option on the action to limit it certain filterable attributes.13 replies
AEAsh Elixir
•Created by Robert Graff on 7/28/2023 in #support
Key :editing_tenant not found
Just starting to explore AshAdmin.
I'm not sure how AshAdmin interacts with multitenancy. For context, some of my apis are multitenancy but not all of them. The tenant for web is via a url slug. For graphql, it's a header. When admin starts, I'm assuming there won't be a tenant.
9 replies
AEAsh Elixir
•Created by Robert Graff on 7/20/2023 in #support
How do relationships with composite keys work?
I found this mention of composite keys in the docs:
Ideally I need something like:
A similar effect to have scope_key being a tenant.
10 replies
AEAsh Elixir
•Created by Robert Graff on 7/14/2023 in #support
Setting defaults for a form input that is an argument and not an attribute?
I have an update action that takes an argument. In the form for this action, I need to set the default value for the form input. The default value is dependent on the current state of the resource being updated.
I explored using the
default
option for an action argument; however, It accepts a zero-argument function, so there's no way to get the resource being updated.
I explored using the prepare_params
option for AshPhoenix.Form.for_update
but I couldn't find any examples. It's arrity 2 and receives the params but is only called when the form is validated or submitted.
Side quest(ion): what's the difference between prepare_params and transform_params if they're both called only on validate and submit?17 replies
AEAsh Elixir
•Created by Robert Graff on 7/13/2023 in #support
Understanding value_is_key option when managing relationships
Given a relation that uses a ci_string (not uuid):
I would expect this change to work using value_is_key option:
But it gives me this error, but I thought the purpose of
value_is_key
is to not provide a struct:
For reference, this more verbose change does work:
20 replies
AEAsh Elixir
•Created by Robert Graff on 7/5/2023 in #support
How to set belongs_to on in a form
I have a create action for Plan that sets the Product (Plan belongs_to Product)
I have a form that I create like this...
and then a select input
This raises an error:
I tried
forms: [auto?: true]
and then I don't get an error but I also don't get any field.3 replies
AEAsh Elixir
•Created by Robert Graff on 6/26/2023 in #support
AshAuthentication identity :token_context
With the latest release of AshAuthention, I'm getting a DSL error.
My git blame says I added this when migrating to Ash, but I don't remember why or see it referenced in any of the guides.
Any idea what I was trying to do here?
7 replies
AEAsh Elixir
•Created by Robert Graff on 6/15/2023 in #support
Any examples of using can?
I'm trying to see if a user (actor) can perform an update action on target user.
10 replies
AEAsh Elixir
•Created by Robert Graff on 6/8/2023 in #support
Bulk create form
I currently have a phoenix form to create an invite. The form is connected to the create action on the Invite resource. The only field is email.
I want to change the form to accept multiple email addresses--comma separated--and then create multiple invites. The create action currently generates a token and sends an email, so it's bit more complicated than a db insert.
I haven't used manual actions, the new bulk_create feature, or Ash.Flow yet. I'm not sure which is the best route.
I'm thinking of adding a manual bulk_create action to my resource that calls the existing create for each email address.
Feedback?
5 replies
AEAsh Elixir
•Created by Robert Graff on 5/5/2023 in #support
Custom reset password flow not passing policy checks
I have a custom live view with a reset password form.
That I submit like this
I would expect this to pass policy checks, but it doesn't
(I moved the check out of a bypass to have it listed in Policy Breakdown explicitly showing it as a fail)
4 replies
AEAsh Elixir
•Created by Robert Graff on 5/2/2023 in #support
Best way to skip tenant check on a query
In my app I have users and accounts. The accounts are tenants. Users have and belong to many accounts through memberships.
I've made the memberships resource multi-tenant, but now the users can't load their memberships.
Memberships are really co-owned. Should I remove the multi-tenancy? Or is there a way for a query to ignore the tenant check?
14 replies
AEAsh Elixir
•Created by Robert Graff on 4/30/2023 in #support
Create action with multiple nested resources
This is the action to register an account. There are 3 resources at play. An account has many memberships and every membership belongs to a user. The membership resource is simply as has_and_belongs_to_many with a role on it.
When a new account is created, it should always create the account and membership for the owner/user. The user resource has an identity on email and is only created if the user doesn't already exist.
What happens is the membership fails to insert because the user_id is nil.
15 replies
AEAsh Elixir
•Created by Robert Graff on 4/27/2023 in #support
Set error message on attribute using AshAuthentication.Strategy.Password.PasswordValidation
When a password validation fails on a liveview form submitted. How do I get an error on the
:current_password
attribute?
41 replies
AEAsh Elixir
•Created by Robert Graff on 4/27/2023 in #support
Testing with log_in_user
I'm writing tests and have a helper to log_in_user that I found in ash-hq source.
But
user.__metadata__ == %{}
which makes sense since I'm generating the user with Ash.Seed. In ash-hq the user is created by a register action which I assume sets the metadata, but don't see how. I don't have an equivalent register action.
How do I generate this token?3 replies
AEAsh Elixir
•Created by Robert Graff on 4/25/2023 in #support
Resolve notifications warning in when running tests
I'm getting this warning when running my test suite. It's coming from (I think) AshAuthentication sending confirmation emails.
I'm not sure how to resolve it.
3 replies
AEAsh Elixir
•Created by Robert Graff on 4/21/2023 in #support
How to compare a seed and loaded resource?
I thought
strip_metadata()
would make the comparable
Are there any showcase apps that have some good example test suites?8 replies
AEAsh Elixir
•Created by Robert Graff on 4/18/2023 in #support
Identity on two attributes causing errors
I have an identity on two attributes (context, and token). I would expect this to require a unique context <> token. But it's not allowing duplicate contexts.
Here's my resource:
Here's the error:
What am I missing?
9 replies
AEAsh Elixir
•Created by Robert Graff on 4/17/2023 in #support
Handling an %Ash.Error.Invalid{} in LiveView
Sorry for the noob question, but the AshPhoenix guide doesn't show any error handling.
This is the code that I assumed would work, but update returns a
{:error, %Ash.Error.Invalid{} }
How do I get those errors onto the form?
15 replies