-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support @defer directive #2318
Support @defer directive #2318
Conversation
Some additional context from Apollo Defer: apollographql/apollo-server#2700 |
Looking at the Relay test schema |
In this branch I created support for @stream: Some checks and optimizations are missing. But the first tests with Relay were positive: |
@morrys Thanks for your effort 👍 About the next steps for merging this PR please see my answer in #2319: @morrys @lilianammmatos Can you please review each other PRs and figure out how to collaborate? |
@IvanGoncharov yes the two PR add the same functionality. |
Hello to all,
this PR allows to support the @defer directive. Although the implementation is mostly complete, the PR is in draft to discuss it together and evaluate its integration.
In the PR I also created tests and I performed the integration tests with Relay, express-graphql & fetch-multipart-graphql with positive results.
In summary how I implemented defer:
graphql-js/src/execution/execute.js
Lines 663 to 668 in 4226f23
resolverResult: ResultResolver
new property in ExecutionContext which allows the management of the results to be returned at the end of the executionAsyncIterable<Promise<ExecutionResult> | PromiseOrValue<ExecutionResult>;
. UsingisAsyncIterable (result)
it is possible to distinguish if there are deferred results.this is a slow motion gif of how it works.
Let me know if more information is needed.
Thank you
Lorenzo