Remove/Limit FilterInput and SortInput fields from a specific action in GraphQL
So, let's say I have custom fields that I added to my action to handle filtering and sorting, for example:
If I create a graphQL query from that action, it will contain the
FilterInput
and SortInput
arguments (see image), is there a way to remove this so my query will only be filterable and sortable by the fields I want?
Also, both FilterInput
and SortInput
seems to basically allow filtering and sorting through all the fields that my resource returns. Is there some way that I can limit that for a specific action somehow?
For example, I would like to actually remove the :min_price
and :max_price
arguments from my action and make FilterInput
only support the initialPrice
(which is the field that these two arguments compare with).
5 Replies
🤔 I think right now there is not a way to customize the filter and sort objects in ash_graphql
We can add an option to tell it that you don't want a given action to be filterable/sortable using the automatic behavior
Whats the reasoning by not supporting the more flexible filter/sort that we add automatically? Happy to add options to customize/trim it down
My main concern is that this would allow the user of the API to create queries that are not well optimized in the database, making it do a seq scan or something like this degrading the overall db performance.
I understand that this is the whole point of GraphQL, but I'm still a little bit skeptical regarding giving too much freedom to the APIs users in this case.
Yeah, that makes sense 🙂 well if you don’t mind opening a ticket on ash_graphql I’ll make the filter and sort types optional 🙂
@Zach Daniel done: https://github.com/ash-project/ash_graphql/issues/55
🥳