Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow up to this pr: #89
Added a
lazy_eval
method to chain methods together.I called it
lazy_eval
instead oflazy
to avoid breaking changes.Follows Enumerator::Lazy with
eager
andforce
methods that only become available afterlazy_eval
is called.eager
tells the loader to stop accumulating methods in the lazy chain and force a real evaluation on the next call.force
tells the loader to sync immediately (kind of redundant, you shouldn't use lazy_eval if you're gonna force)In graphql, a sync is implicitly done at the correct time so
eager
isn't required to break the lazy chain. I automatically disable lazy chaining after a sync. This allows a nice looking:But in non graphql contexts, you'd have to do:
The code is relatively easy to understand, and the api is fairly analogous to Enumerator::Lazy, but I understand if you think it's too complex. Let me know if you have any thoughts, was fun to work on regardless.