Skip to content

Incremental Delivery spec draft #1110

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

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7ff9d0b
Extract common logic from ExecuteQuery, ExecuteMutation and ExecuteSu…
benjie Apr 28, 2023
8f4168b
Change ExecuteSelectionSet to ExecuteGroupedFieldSet
benjie Apr 28, 2023
69de3fd
Correct reference to MergeSelectionSets
benjie Aug 21, 2023
667364a
moves Field Collection section earlier
yaacovCR Feb 15, 2024
bb23a1b
Introduce `@defer` directive
yaacovCR Feb 15, 2024
65be49a
refactor a few lines out of YieldSubsequentResults
yaacovCR Jun 13, 2024
12513e1
add a word or two about which child nodes are being promoted
yaacovCR Jun 18, 2024
7284e2d
be more graphy
yaacovCR Jun 18, 2024
3fd7b90
fix timing
yaacovCR Jun 19, 2024
d3ab7a3
reuse function
yaacovCR Jun 19, 2024
853b031
fix
yaacovCR Jun 19, 2024
57d6193
rename BuildGraph to GraphFromRecords
yaacovCR Jun 19, 2024
fe42e8c
reword recursive abort case
yaacovCR Jun 19, 2024
d8966dc
bring BuildFieldPlan in line with implementation
yaacovCR Jul 17, 2024
136afea
rename "deferred grouped field set record" to "execution group"
yaacovCR Jul 17, 2024
f11f956
rename ExecuteExecutionGroup to CollectExecutionGroup
yaacovCR Jul 17, 2024
5e0a10a
properly initialize deferUsages with their parents
yaacovCR Jul 18, 2024
5490ed1
move Field Collection back to where it was
yaacovCR Jul 18, 2024
22dfbb8
f
yaacovCR Jul 18, 2024
b80d53b
use fieldDetailsList consistently
yaacovCR Jul 18, 2024
66536f4
add info re: data structures
yaacovCR Jul 18, 2024
a88da21
rename FieldPlan to ExecutionPlan
yaacovCR Jul 20, 2024
741605b
path => label
yaacovCR Jul 24, 2024
7251c7b
add missing arguments
yaacovCR Jul 25, 2024
2d121f1
add missing return value
yaacovCR Jul 25, 2024
c2d83a0
fix some renaming around CollectExecutionGroups and ExecuteExecutionG…
yaacovCR Jul 25, 2024
ccc26f2
Correct argument name
yaacovCR Aug 26, 2024
879818f
clarify errors from ExecuteExecutionPlan
yaacovCR Aug 26, 2024
a020ea1
add initial versions of explanations for the algorithms in the "Execu…
yaacovCR Aug 26, 2024
a6c164d
add subheadings
yaacovCR Sep 5, 2024
f15235a
adjust heading
yaacovCR Sep 6, 2024
50f644d
Initialize graph
yaacovCR Sep 6, 2024
afe40cd
adjust YieldSubsequentResults algorithm per review
yaacovCR Sep 6, 2024
606a6f1
reuse GetIncrementalResult() for the error case
yaacovCR Sep 6, 2024
f44deb5
add descriptions and fix bug within GetNewRootNodes, it needs the old…
yaacovCR Sep 6, 2024
f8f6f35
finish addressing review comments
yaacovCR Sep 6, 2024
4f8e668
add missing word
yaacovCR Sep 6, 2024
89983ce
Add Response Section for defer/stream (#4)
robrichard Sep 18, 2024
d40130d
Add directives and validation sections (#5)
robrichard Sep 18, 2024
f7e9124
Add examples to Response section
robrichard Nov 1, 2024
8e9cbcb
skip deferred fragment spread when already in visited fragments
robrichard Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor a few lines out of YieldSubsequentResults
  • Loading branch information
yaacovCR authored and robrichard committed Nov 1, 2024
commit 65be49a55421db5bccdc716443d37d136dea31bc
80 changes: 51 additions & 29 deletions spec/Section 6 -- Execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,15 +359,12 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
- Add {incrementalDataRecord} to {graph} as a new Pending Data node directed
from the {pendingResults} that it completes, adding each of {pendingResults}
to {graph} as new nodes, if necessary, each directed from its {parent}, if
defined, recursively adding each {parent} as necessary.
- Prune root nodes of {graph} containing no direct child Incremental Data
Records, repeatedly if necessary, promoting any direct child Deferred
Fragments of the pruned nodes to root nodes. (This ensures that no empty
fragments are reported as pending).
- Let {newPendingResults} be the set of root nodes in {graph}.
- Let {pending} be the result of {GetPending(newPendingResults)}.
- Let {hasNext} be {true}.
- Yield an unordered map containing {data}, {errors}, {pending}, and {hasNext}.
defined, recursively adding each {parent} as necessary until
{incrementalDataRecord} is connected to {graph}.
- Let {pendingResults} be the result of {GetNonEmptyNewPending(graph)}.
- Prune root nodes from {graph} not in {pendingResults}, repeating as necessary
until all root nodes in {graph} are also in {pendingResults}.
- Yield the result of {GetInitialResult(data, errors, pending)}.
- For each completed child Pending Incremental Data node of a root node in
{graph}:
- Let {incrementalDataRecord} be the Pending Incremental Data for that node;
Expand All @@ -383,7 +380,7 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
parents.
- Let {hasNext} be {false}, if {graph} is empty.
- Yield an unordered map containing {completed} and {hasNext}.
- Continue to the next completed child Incremental Data node in {graph}.
- Continue to the next completed Pending Incremental Data node.
- Replace {node} in {graph} with a new node corresponding to the Completed
Incremental Data for {result}.
- Add each {incrementalDataRecord} of {incrementalDataRecords} on {result} to
Expand All @@ -393,7 +390,7 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
- Let {completedIncrementalDataNodes} be the set of completed Incremental Data
nodes that are children of {completedDeferredFragments}.
- If {completedIncrementalDataNodes} is empty, continue to the next completed
child Incremental Data node in {graph}.
Pending Incremental Data Node.
- Initialize {incremental} to an empty list.
- For each {node} of {completedIncrementalDataNodes}:
- Let {incrementalDataRecord} be the corresponding record for {node}.
Expand All @@ -405,32 +402,57 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
- Append {GetCompletedEntry(pendingResult)} to {completed}.
- Remove {pendingResult} from {graph}, promoting its child nodes to root
nodes.
- Prune root nodes of {graph} containing no direct child Incremental Data
Records, as above.
- Let {hasNext} be {false} if {graph} is empty.
- Let {incrementalResult} be an unordered map containing {hasNext}.
- If {incremental} is not empty, set the corresponding entry on
{incrementalResult} to {incremental}.
- If {completed} is not empty, set the corresponding entry on
{incrementalResult} to {completed}.
- Let {newPendingResults} be the set of new root nodes in {graph}, promoted by
the above steps.
- If {newPendingResults} is not empty:
- Let {pending} be the result of {GetPending(newPendingResults)}.
- Set the corresponding entry on {incrementalResult} to {pending}.
- Yield {incrementalResult}.
- Let {newPendingResults} be a new set containing the result of
{GetNonEmptyNewPending(graph, pendingResults)}.
- Add all nodes in {newPendingResults} to {pendingResults}.
- Prune root nodes from {graph} not in {pendingResults}, repeating as
necessary until all root nodes in {graph} are also in {pendingResults}.
- Let {pending} be the result of {GetPendingEntry(newPendingResults)}.
- Yield the result of {GetIncrementalResult(graph, incremental, completed,
pending)}.
- Complete this incremental result stream.

GetPending(newPendingResults):
GetNonEmptyNewPending(graph, oldPendingResults):

- If not provided, initialize {oldPendingResults} to the empty set.
- Let {rootNodes} be the set of root nodes in {graph}.
- For each {rootNode} of {rootNodes}:
- If {rootNodes} is in {oldPendingResults}:
- Continue to the next {rootNode}.
- If {rootNode} has no children Pending Incremental Data nodes:
- Let {children} be the set of child Deferred Fragment nodes of {rootNode}.
- Remove {rootNode} from {rootNodes}.
- Add each of the nodes in {children} to {rootNodes}.
- Return {rootNodes}.

GetInitialResult(data, errors, pendingResults):

- Let {pending} be the result of {GetPendingEntry(pendingResults)}.
- Let {hasNext} be {true}.
- Return an unordered map containing {data}, {errors}, {pending}, and {hasNext}.

GetPendingEntry(pendingResults):

- Initialize {pending} to an empty list.
- For each {newPendingResult} of {newPendingResults}:
- Let {id} be a unique identifier for {newPendingResult}.
- Let {path} and {label} be the corresponding entries on {newPendingResult}.
- For each {pendingResult} of {pendingResult}:
- Let {id} be a unique identifier for {pendingResult}.
- Let {path} and {label} be the corresponding entries on {pendingResult}.
- Let {pendingEntry} be an unordered map containing {id}, {path}, and {label}.
- Append {pendingEntry} to {pending}.
- Return {pending}.

GetIncrementalResult(graph, incremental, completed, pending):

- Let {hasNext} be {false} if {graph} is empty, otherwise, {true}.
- Let {incrementalResult} be an unordered map containing {hasNext}.
- If {incremental} is not empty:
- Set the corresponding entry on {incrementalResult} to {incremental}.
- If {completed} is not empty:
- Set the corresponding entry on {incrementalResult} to {completed}.
- If {pending} is not empty:
- Set the corresponding entry on {incrementalResult} to {pending}.
- Return {incrementalResult}.

GetIncrementalEntry(incrementalDataRecord, graph):

- Let {deferredFragments} be the Deferred Fragments incrementally completed by
Expand Down