-
-
Notifications
You must be signed in to change notification settings - Fork 566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify deferred/promise implementation #581
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the simplification 👍
- Added few comments
- I think
Deferred extends SyncPromise
is a BC break as result of$deferred instanceof SyncPromise
with this change changes fromfalse
totrue
so might need to document it. - Do we need Deferred at all?
Wow, thanks for the quick actions. Unfortunately it will take me a while, seems due to dependencies I can't just upgrade to this commit and need to fiddle around manually. Will keep you updated, also regarding the batch sequence order. |
Had a dependency issue as well and could resolve it by aliasing the reference: "webonyx/graphql-php": "dev-simplify-deferred as 0.13.8" |
I agree that we should add a note about this in Upgrade.md
We do for now. First for BC, second to enforce |
yes this will have an impact on DataLoader but a positive impact with this change it will make the implementation easier since we dealing with a unique object instead of two. |
@vladar i tried this branch in Lighthouse and ran our test suite against it, seems to be working fine. |
61b0907
to
8d37049
Compare
Hi! I been testing this with WPGraphQL. It's bit behind with graphql-php versions but this change in particular does not cause any issues with our tests. I'm working on a field level caching solution for WPGraphQL at the moment and this change would help a lot with that since I need to tap into the promise chains so I can capture the resolved values. Here's simplified version of what I'm trying to do add_filter('graphql_resolve_field', function( $defer, $field_key ) {
return $defer->then(function($result) use ($field_key) {
write_cache( $field_key, wp_json_encode($result));
return $result;
});
}, 100, 2); Where This does not work with the latest graphql-php stable release because the This PR fixes that issue nicely 👌 |
Merge
Deferred
andSyncPromise
. This simplifies things a bit and allows certain new features (like Deferred chaining):The caveats are:
wait
for a specific promise anymore. The whole chain of promises has to be resolved beforewait
returns (as we have a single queue now).So I encourage anyone using
deferred
resolvers to try this branch and report some feedback.@mcg-web Can you check if this will affect your DataLoader implementation somehow?
CC @mfn @spawnia
Fixes #573