graphql-ruby icon indicating copy to clipboard operation
graphql-ruby copied to clipboard

Support lazy enumerators for @stream

Open rmosolgo opened this issue 1 year ago • 1 comments
trafficstars

Fixes #4907

TODO:

  • [ ] Maintain compatibility with existing batching
  • [ ] Add a test for this behavior in particular
  • [ ] Find an implementation other than recursion

rmosolgo avatar Apr 17 '24 19:04 rmosolgo

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 @stream in particular?

rmosolgo avatar Apr 24 '24 13:04 rmosolgo

This is still very much on my radar, but I don't plan to continue work on this branch in particular.

rmosolgo avatar Apr 11 '25 11:04 rmosolgo