You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the same time, inside the same request its a good performance characteristic to avoid re-calling a resolver that threw an error with that same input.
It seems that we would be save to cache only pure functions, and caching errors would be desirable as well (we'd always get the same errors if we run it the same).
Whereas caching of impure functions seems like a risky idea both for errors and results (!) (as these can change, depending on the outside's state).
So it seems to be a good default behaviour to cache only pure functions.
How would we know if a function is pure?
There are no easy ways known to me..
Perhaps we could try to infer it from function's body (akin to how it's done with inference of inputs and outputs) or run it in an isolated environment and see if it behaves the same, but these may not be accurate.
A good way seems to be to let users mark functions as pure/impure. (impure being the default (safe defaults))
And perhaps cacheable/not cacheable. (In case some users would like to cache an impure function at their own risk) (not cacheable being the default) Upd: I found that this mechanism is already implemented, as described in the docs. However, default is to cache, which is risky for impure functions.
I'm thinking that this might be better as a configurable option per resolver, we can keep it as-is for the default and allow the user to flag a resolver to set the behavior. This way, the user will have more control over handling exceptions per resolver.
When a resolver throws an error, it must not cache that error value.
As of now, it does cache that error value, and in case it's a persistent cache you end up always getting the error.
The text was updated successfully, but these errors were encountered: