How to run custom resource extension before validators
Hi there,
I'm writing my first
Ash.Resource
extension and having some issues I don't know how to solve. This is my simple extension so far:
All it does is add some attributes to the resource. But when I add EKG.Extensions.ScenePlaceable
to the list of extensions of my resource I'm now getting this compile error:
So looks like that validation is running before my extension has a chance to add the attributes? As far as I'm aware the docs don't mention how to configure an extension to get around this issue, but I'm sure the fix is easy. Thank you for your help!Solution:Jump to solution
You can do this in your transformer:
```elixir
def before?(Ash.Resource.Transformers.DefaultAccept), do: true
def before?(_), do: false...
5 Replies
Solution
You can do this in your transformer:
its something I'd like to improve, but at the moment you basically have to know what thing produces the error and place yourself before/after it accordingly
Hmm, I tried adding that before (and just again to confirm) and I'm getting the error unfortunately
Hmm, this may be due to how I'm also using a custom base resource...
I have a feeling the options I'm giving are not being merged in correctly
That should be fine 🤔 it could be a different transformer showing that error.
To follow up, the issue was with my custom resource. I had to update it to this:
TBH, I still don't really get Elixir macros and often just have to bumble around until something just works â„¢