Ash FrameworkAF
Ash Framework3y ago
3 replies
Blibs

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?
Was this page helpful?