[RFC] Alternative proposal for @stream/@defer#1018
Closed
Conversation
✅ Deploy Preview for graphql-spec-draft ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
1b56d86 to
df84d1b
Compare
Member
Author
|
This PR is out of date versus what is currently being proposed. Closing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This RFC is an alternative solution to incremental delivery. This is a very early draft to enable sharing this solution with the incremental delivery working group, and, if ratified, may either be merged into @robrichard et al's excellent work in #742, or supersede it.
This PR currently only addresses the algorithms in the execution part of the specification (and is based off of a recent draft of the GraphQL specification, rather than any preceding work), so for accompanying specification text regarding the syntax and directives of incremental delivery, please see the excellent prior work in #742.
The goal of this proposal is to address the needs of incremental delivery whilst:
@streamand@deferdirectives from the request.@defer'd or@stream'd selection set are sent atomically in a single event, such thatMyFragment: __typenameand other fragment identification approaches can be relied upon to confirm that the entire fragment is present.Non-goals of this proposal are:
@streamor@deferdirectives issued in the request.@stream/@deferdirectives in the request and any components in the response.@defers... @defer { ... @defer { a } }is equivalent to... @defer { a }, but we might change this.The significant change in this RFC is that it is built around the field merging algorithm that we already have, and allows merging
@defers not just within a single selection set, but across the entire request. It works based on "defer layers" - thus for a query such as:{ a { b ... @defer { c { c1 } } d { e ... @defer { f } } } g ... @defer { a { c { ... @defer { c2 } } } h } }The first query to be resolved is as before:
{ a { b d { e } } g }Yielding something like:
Next the first layer of
@defer'd leaves is evaluated, which results in the following selection sets being evaluated at the following paths:[], selection:{ h }['a'], selection:{ c { c1 } }['a', 'd'], selection:{ f }All three of these are evaluated (separately, in parallel) and then grouped together into the same event, something like:
Finally we look at the next layer of
@defer, which would yield:['a', 'c'], selection:{ c2 }Which would yield:
and finally:
(Note: we can probably optimize this to put the
hasNext: falsein the previous payload instead, but I've not yet tried to write that into the spec text.)