graphql-ruby
graphql-ruby copied to clipboard
Print warning when custom validators are detected
Problem
Custom validators with I/O operations may fail unexpectedly due to GraphQL's default validate_timeout setting. Long-running I/O operations may not be terminated midway, resulting in unpredictable behavior.
See these PRs for more context: Manual timeout implementation: https://github.com/rmosolgo/graphql-ruby/pull/5263 Validate_timeout default value implementation: https://github.com/rmosolgo/graphql-ruby/pull/5258
We should make the risk of adding I/O bound custom validators more "in your face" in the gem for consumers.
solution
Print a warning when a custom validator is registered.
Hey, thanks for looking into this. What if we made validate_timeout I/O-safe instead? I think the visit hooks in this module could be the place for that: https://github.com/rmosolgo/graphql-ruby/blob/6120645fe4785af403bcf32ea83413fea810190a/lib/graphql/static_validation/base_visitor.rb#L55
Implementation-wise, it'd be very much like #5263. What do you think?
What if we made
validate_timeoutI/O-safe instead?
I'm very much on board with that. Let's do it!