Expand Ash.Query.Operator built_in operators
Right now, ash comes with a bunch of built-in operator for queries (
is_nil
, eq
, in
, less_than
, etc).
These are great, but it is not enough in some cases. For example, let's say I want to create a similarity
operator?
The obvious answer is that I can implement it myself using the Ash.Query.Operator.__using__/1
macro.
The problem with that is that I can't see how to make these new operators available globally for my resources.
For example, if we look in AshGraphql
, the resource.ex
file will create the filters based in the built-in filters using the Ash.Filter.builtin_operators()
inside the filter_type
function. AFAIK there is no way to expand the built-in operators with a custom one, to make the Ash.Filter.builtin_operators()
return also my custom operators, or, specifically for AshGraphql
make the filter_type
function also fetch my custom operators.
Is there a workaround for that that I'm not aware? And if not, is that something that is planned?2 Replies
IIRC, that kind of thing is being tracked by this issue: https://github.com/ash-project/ash/issues/374
GitHub
Custom predicates & operators · Issue #374 · ash-project/ash
These would be exposed to the expression syntax in code, and can be made available over api extensions as well. I'm thinking something like this: support a custom configured list of functions t...
in the meantime, what you'd do is add similarity calculations to your resources
i.e