graphql-ruby
graphql-ruby copied to clipboard
Support lazy enumerators for @stream
trafficstars
Fixes #4907
TODO:
- [ ] Maintain compatibility with existing batching
- [ ] Add a test for this behavior in particular
- [ ] Find an implementation other than recursion
Looking at how this played out, I have a few big questions still to work out:
- Currently, each list item calls the next one via recursion. This will make really big Ruby stacks, hogging memory. A better approach would be "trampolining", something I spiked several years ago, where different steps of execution actually return to the main caller, which dispatches steps. That change might be necessary to support this feature effectively.
- The current batching behavior expects each list item to request its own data, then resolve requests for all list items in a single batch. That's impossible with this approach where each item is handled separately. How can I support both without expensive
.is_a?checks on every object? Maybe detect@streamin particular?
This is still very much on my radar, but I don't plan to continue work on this branch in particular.