Make some calculation action specific
So, if I want to do a specific change for an action, I can always add
, where: [action_is(:create)]
or something like this.
I tried the same for calculations but it doesn't seem like it has the same functionality.
So, if I want to do a calculation that is only relevant for a specific action, is there some way to do it?3 Replies
Why would a calculation only be relevant for a specific action?
For example, I have two actions for properties, one will return a list of properties, and the other one only one property.
In the case of a list of properties, I will need to do a query per property to the database to get the calculation data I need, so if the query returns 900 properties, then I will do 901 queries to the DB.
So, I wanted to limit that calculation to only the action that returns a single property since that way I can avoid frontend developers trashing my DB in unexpected ways.
Well, you can avoid that by using calculations properly to make fewer queries
but I'm not sure if we actually have a way in ash_graphql to hide calculations per query/mutation, so we'd need to add that.