I don’t see an easy way for this, may be you can write a Relay pass that does the cast?
Good point, a PR welcome.