Skip to content

Commit 47556fa

Browse files
committed
Stream
1 parent 4378cb4 commit 47556fa

File tree

1 file changed

+91
-25
lines changed

1 file changed

+91
-25
lines changed

spec/Section 6 -- Execution.md

Lines changed: 91 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ initialStreams, variableValues):
210210
{deferredDetailsForPath}.
211211
- Let {objectValue} be the value for key {objectValue} in
212212
{deferredDetailsForPath}.
213-
- Let {allFieldDetails} be the value for key {allFieldDetails} in
213+
- Let {fieldDetails} be the value for key {fieldDetails} in
214214
{deferredDetailsForPath}.
215215
- Let {fields} be a list of all the values of the {field} key in the
216-
entries of {allFieldDetails}.
216+
entries of {fieldDetails}.
217217
- Let {selectionSet} be a new selection set consisting of {fields}.
218218
- Let {data}, {childDefers} and {childStreams} be
219219
{ExecuteSelectionSet(selectionSet, objectType, objectValue,
@@ -250,10 +250,53 @@ initialStreams, variableValues):
250250
- Add {pendingStream} to {remainingStreams}.
251251
- Add to {completed} an unordered map containing {id}.
252252
- Optionally, {FlushStream()}.
253-
- Else
253+
- Else:
254254
- Assert: {remainingStreams} is not empty.
255-
- Let {stream} be the first entry in {remainingStreams}.
256-
- Remove {stream} from {remainingStreams}.
255+
- Let {pendingStream} be the first entry in {remainingStreams}.
256+
- Remove {pendingStream} from {remainingStreams}.
257+
- Let {id} be the value for key {id} in {pendingStream}.
258+
- Let {streamDetails} be the value for key {streamDetails} in
259+
{pendingStream}.
260+
- Let {parentPath} be the value for key {path} in {streamDetails}.
261+
- Let {itemType} be the value for key {itemType} in {streamDetails}.
262+
- Let {fields} be the value for key {fields} in {streamDetails}.
263+
- Let {remainingValues} the the value for key {remainingValues} in
264+
{streamDetails}.
265+
- Let {initialCount} be the value for key {initialCount} in {streamDetails}.
266+
- Let {fieldDetails} be the value for key {fieldDetails} in {streamDetails}.
267+
- For each entry {remainingValue} with zero-based index
268+
{remainingValueIndex} in {remainingValues}.
269+
- Let {index} be the result of adding {initialCount} to
270+
{remainingValueIndex}.
271+
- Let {path} be a copy of {parentPath} with {index} appended.
272+
- Let {value}, {childDefers}, {childStreams} be the result of calling
273+
{CompleteValue(itemType, fields, remainingValue, variableValues, path)}.
274+
- Let {childErrors} be the list of all _field error_ raised while
275+
completing the value.
276+
- Let {incrementalPayload} be an unordered object containing {path},
277+
{value}, and the key {errors} with value {childErrors}.
278+
- Append {incrementalPayload} to {incremental}.
279+
- If {childDefers} is not an empty object:
280+
- Let {id} be {nextId} and increment {nextId} by one.
281+
- Let {path} be the longest common path prefix list for every path list
282+
key in {childDefers}, or the empty list if no such list exists.
283+
- TODO: This really needs rewording!
284+
- Let {pendingPayload} be an unordered map containing {id}, {path}.
285+
- Add {pendingPayload} to {pending}.
286+
- Let {defers} be {childDefers}.
287+
- Let {pendingDefer} be an unordered map containing {id}, {defers}.
288+
- Add {pendingDefer} to {remainingDefers}.
289+
- If {childStreams} is not an empty list:
290+
- For each entry {streamDetails} in {childStreams}:
291+
- Let {id} be {nextId} and increment {nextId} by one.
292+
- Let {path} be the value for the key {path} in {streamDetails}.
293+
- Let {pendingPayload} be an unordered map containing {id}, {path}.
294+
- Add {pendingPayload} to {pending}.
295+
- Let {pendingStream} be an unordered map containing {id},
296+
{streamDetails}.
297+
- Add {pendingStream} to {remainingStreams}.
298+
- Add to {completed} an unordered map containing {id}.
299+
- Optionally, {FlushStream()}.
257300
- {FlushStream(false)}.
258301
- Complete {responseStream}.
259302

@@ -488,24 +531,22 @@ parentPath):
488531
{objectType}.
489532
- If {fieldType} is defined:
490533
- If every entry in {fieldDetails} has {isDeferred} set to {true}:
491-
- Let {deferredDetailsForPath} be the object in {defers} for {path}; if no
492-
such list exists, create it as an unordered map containing {objectType},
493-
{objectValue} and {allFieldDetails}, where {allFieldDetails} is an empty
494-
list.
495-
- Let {group} be the value in {deferredDetailsForPath} for key
496-
{allFieldDetails}.
497-
- Append {fieldDetails} to {allFieldDetails}.
534+
- Add an entry to {defers} with key {path} and value an unordered map
535+
containing {objectType}, {objectValue} and {fieldDetails}.
498536
- Else:
499-
- Let {responseValue}, {childDefers}, {childStreams} be
500-
{ExecuteField(objectType, objectValue, fieldType, fieldDetails,
501-
variableValues, path)}.
502-
- Add the entries of {childDefers} into {defers}. Note: {childDefers} and
503-
{defers} will never have keys in common.
504-
- For each entry {stream} in {childStreams}, append {stream} to {streams}.
505-
- If {responseValue} is not null and {fieldType} is a list type and
506-
{field} provides the directive `@stream`, let {streamDirective} be that
507-
directive. If {streamDirective}'s {if} argument is not {false} and is
508-
not a variable in {variableValues} with the value {false}:
537+
- Let {fields} be a list of all the values of the {field} key in the
538+
entries of {fieldDetails}.
539+
- Let {resolvedValue} be {ExecuteField(objectType, objectValue, fieldType,
540+
fields, variableValues, path)}.
541+
- Let {nullableFieldType} be the inner type of {fieldType} if {fieldType}
542+
is a non-nullable type, otherwise let {nullableFieldType} be
543+
{fieldType}.
544+
- If {nullableFieldType} is a list type and {responseValue} is a
545+
collection of values and {field} provides the directive `@stream`, let
546+
{streamDirective} be that directive. If {streamDirective}'s {if}
547+
argument is not {false} and is not a variable in {variableValues} with
548+
the value {false}:
549+
- Let {itemType} be the inner type of {nullableFieldType}.
509550
- If {streamDirective}'s {initialCount} argument is a variable:
510551
- Let {initialCount} be the value of that variable in
511552
{variableValues}.
@@ -514,14 +555,29 @@ parentPath):
514555
{initialCount} argument.
515556
- If {initialCount} is {null}, not provided, or less than {0} then let
516557
{initialCount} be {0}.
517-
- Let {initialValues} be the first {initialCount} entires in
518-
{responesValue}, and {remainingValues} be the remainder.
558+
- Let {initialValues} be the first {initialCount} entries in
559+
{resolvedValue}, and {remainingValues} be the remainder.
560+
- Let {initialResponseValue}, {childDefers}, {childStreams} be the
561+
result of calling {CompleteValue(nullableFieldType, fields,
562+
initialValues, variableValues, path)}.
563+
- Add the entries of {childDefers} into {defers}. Note: {childDefers}
564+
and {defers} will never have keys in common.
565+
- For each entry {stream} in {childStreams}, append {stream} to
566+
{streams}.
519567
- Set {initialValues} as the value for {responseKey} in {resultMap}.
520568
- If there are (or may be) values in {remainingValues}:
521569
- Let {streamDetails} be an unordered map containing {path},
522-
{remainingValues}, {initialCount} and {fieldDetails}.
570+
{itemType}, {fields}, {remainingValues}, {initialCount} and
571+
{fieldDetails}.
523572
- Append {streamDetails} to {streams}.
524573
- Else:
574+
- Let {responseValue}, {childDefers} and {childStreams} be the result of
575+
{CompleteValue(fieldType, fields, resolvedValue, variableValues,
576+
path)}.
577+
- Add the entries of {childDefers} into {defers}. Note: {childDefers}
578+
and {defers} will never have keys in common.
579+
- For each entry {stream} in {childStreams}, append {stream} to
580+
{streams}.
525581
- Set {responseValue} as the value for {responseKey} in {resultMap}.
526582
- Return {resultMap}, {defers} and {streams}.
527583

@@ -781,6 +837,16 @@ ExecuteField(objectType, objectValue, fieldType, fields, variableValues, path):
781837
{CompleteValue(fieldType, fields, resolvedValue, variableValues, path)}.
782838
- Return {responseValue}, {defers} and {streams}.
783839

840+
ExecuteField(objectType, objectValue, fieldType, fields, variableValues, path):
841+
842+
- Let {field} be the first entry in {fields}.
843+
- Let {fieldName} be the field name of {field}.
844+
- Let {argumentValues} be the result of {CoerceArgumentValues(objectType, field,
845+
variableValues)}
846+
- Let {resolvedValue} be {ResolveFieldValue(objectType, objectValue, fieldName,
847+
argumentValues)}.
848+
- Return {resolvedValue}.
849+
784850
### Coercing Field Arguments
785851

786852
Fields may include arguments which are provided to the underlying runtime in

0 commit comments

Comments
 (0)