Custom type don't show all possible filters in GraphQL Api
In my project I have the following type:
I use it inside a resource like this:
The issue I'm having is that now I can't see all the default filters that AshGraphQL generate for built-in supported fields.
So, in this case, AshGraphQL will generate a
PropertyFilterPrice
type which only have a isNil
option, where, before, then that field was a :decimal
, it would show a bunch of filter options like eq
, greaterThan
, greaterThanOrEqual
, in
, etc.
So, the question is, what is the correct approach to implement or make these filters available for custom types?5 Replies
š¤ good question š
I tried to find how/where the built-in fields define these filters, but failed miserably š
can you try this:
(in addition to
graphql_type
)Yep, I was about to mention that haha. I had just found out that the
AshGraphql.Resource.filter_fields
function was reaching the rescue
code block with a (RuntimeError) Could not determine graphql type for Marketplace.Ash.Types.Currency, please define: graphql_input_type/1!
error.
Maybe it would be nice to have a config option in ash_graphql
to enable "warnings" from exceptions like this? Something like config :ash_graphql, enable_compile_warnings?: true
that way I would catch that error without having to change the resource.ex code directly to print that warningIām not sure if that specific solution would work, but if you could open an issue illustrating the problem that would be great š