From d2e280ac3eaa90adf2b6118cf35687a21bef8e15 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Mon, 28 Aug 2023 13:12:47 -0400 Subject: [PATCH] incremental: utilize `id` and `subPath` rather than `path` and `label` (#3960) updates response format to fully match new format further discussed at https://github.com/graphql/defer-stream-wg/discussions/69 --- src/execution/IncrementalPublisher.ts | 79 ++++- src/execution/__tests__/defer-test.ts | 396 +++++++++++----------- src/execution/__tests__/mutations-test.ts | 12 +- src/execution/__tests__/stream-test.ts | 272 +++++++-------- 4 files changed, 406 insertions(+), 353 deletions(-) diff --git a/src/execution/IncrementalPublisher.ts b/src/execution/IncrementalPublisher.ts index 40dbee1085..d34ae102c2 100644 --- a/src/execution/IncrementalPublisher.ts +++ b/src/execution/IncrementalPublisher.ts @@ -100,7 +100,8 @@ export interface IncrementalDeferResult< > { errors?: ReadonlyArray; data: TData; - path: ReadonlyArray; + id: string; + subPath?: ReadonlyArray; extensions?: TExtensions; } @@ -110,7 +111,8 @@ export interface FormattedIncrementalDeferResult< > { errors?: ReadonlyArray; data: TData; - path: ReadonlyArray; + id: string; + subPath?: ReadonlyArray; extensions?: TExtensions; } @@ -120,7 +122,8 @@ export interface IncrementalStreamResult< > { errors?: ReadonlyArray; items: TData; - path: ReadonlyArray; + id: string; + subPath?: ReadonlyArray; extensions?: TExtensions; } @@ -130,7 +133,8 @@ export interface FormattedIncrementalStreamResult< > { errors?: ReadonlyArray; items: TData; - path: ReadonlyArray; + id: string; + subPath?: ReadonlyArray; extensions?: TExtensions; } @@ -146,13 +150,13 @@ export type FormattedIncrementalResult< | FormattedIncrementalStreamResult; export interface PendingResult { + id: string; path: ReadonlyArray; label?: string; } export interface CompletedResult { - path: ReadonlyArray; - label?: string; + id: string; errors?: ReadonlyArray; } @@ -178,6 +182,7 @@ export interface FormattedCompletedResult { * @internal */ export class IncrementalPublisher { + private _nextId = 0; private _released: Set; private _pending: Set; @@ -372,7 +377,10 @@ export class IncrementalPublisher { const pendingResults: Array = []; for (const pendingSource of pendingSources) { pendingSource.pendingSent = true; + const id = this._getNextId(); + pendingSource.id = id; const pendingResult: PendingResult = { + id, path: pendingSource.path, }; if (pendingSource.label !== undefined) { @@ -383,6 +391,10 @@ export class IncrementalPublisher { return pendingResults; } + private _getNextId(): string { + return String(this._nextId++); + } + private _subscribe(): AsyncGenerator< SubsequentIncrementalExecutionResult, void, @@ -554,7 +566,9 @@ export class IncrementalPublisher { } const incrementalResult: IncrementalStreamResult = { items: subsequentResultRecord.items, - path: subsequentResultRecord.streamRecord.path, + // safe because `id` is defined once the stream has been released as pending + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + id: subsequentResultRecord.streamRecord.id!, }; if (subsequentResultRecord.errors.length > 0) { incrementalResult.errors = subsequentResultRecord.errors; @@ -571,11 +585,8 @@ export class IncrementalPublisher { for (const deferredGroupedFieldSetRecord of subsequentResultRecord.deferredGroupedFieldSetRecords) { if (!deferredGroupedFieldSetRecord.sent) { deferredGroupedFieldSetRecord.sent = true; - const incrementalResult: IncrementalDeferResult = { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - data: deferredGroupedFieldSetRecord.data!, - path: deferredGroupedFieldSetRecord.path, - }; + const incrementalResult: IncrementalDeferResult = + this._getIncrementalDeferResult(deferredGroupedFieldSetRecord); if (deferredGroupedFieldSetRecord.errors.length > 0) { incrementalResult.errors = deferredGroupedFieldSetRecord.errors; } @@ -592,15 +603,49 @@ export class IncrementalPublisher { }; } + private _getIncrementalDeferResult( + deferredGroupedFieldSetRecord: DeferredGroupedFieldSetRecord, + ): IncrementalDeferResult { + const { data, deferredFragmentRecords } = deferredGroupedFieldSetRecord; + let maxLength = deferredFragmentRecords[0].path.length; + let maxIndex = 0; + for (let i = 1; i < deferredFragmentRecords.length; i++) { + const deferredFragmentRecord = deferredFragmentRecords[i]; + const length = deferredFragmentRecord.path.length; + if (length > maxLength) { + maxLength = length; + maxIndex = i; + } + } + const recordWithLongestPath = deferredFragmentRecords[maxIndex]; + const longestPath = recordWithLongestPath.path; + const subPath = deferredGroupedFieldSetRecord.path.slice( + longestPath.length, + ); + const id = recordWithLongestPath.id; + const incrementalDeferResult: IncrementalDeferResult = { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + data: data!, + // safe because `id` is defined once the fragment has been released as pending + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + id: id!, + }; + + if (subPath.length > 0) { + incrementalDeferResult.subPath = subPath; + } + + return incrementalDeferResult; + } + private _completedRecordToResult( completedRecord: DeferredFragmentRecord | StreamRecord, ): CompletedResult { const result: CompletedResult = { - path: completedRecord.path, + // safe because `id` is defined once the stream has been released as pending + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + id: completedRecord.id!, }; - if (completedRecord.label !== undefined) { - result.label = completedRecord.label; - } if (completedRecord.errors.length > 0) { result.errors = completedRecord.errors; } @@ -736,6 +781,7 @@ export class DeferredGroupedFieldSetRecord { export class DeferredFragmentRecord { path: ReadonlyArray; label: string | undefined; + id: string | undefined; children: Set; deferredGroupedFieldSetRecords: Set; errors: Array; @@ -758,6 +804,7 @@ export class DeferredFragmentRecord { export class StreamRecord { label: string | undefined; path: ReadonlyArray; + id: string | undefined; errors: Array; earlyReturn?: (() => Promise) | undefined; pendingSent?: boolean; diff --git a/src/execution/__tests__/defer-test.ts b/src/execution/__tests__/defer-test.ts index 33c310523b..19a2e1c77f 100644 --- a/src/execution/__tests__/defer-test.ts +++ b/src/execution/__tests__/defer-test.ts @@ -176,7 +176,7 @@ describe('Execute: defer directive', () => { id: '1', }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { @@ -185,10 +185,10 @@ describe('Execute: defer directive', () => { data: { name: 'Luke', }, - path: ['hero'], + id: '0', }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -232,17 +232,17 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { id: '1' } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { incremental: [ { data: { name: 'Luke' }, - path: ['hero'], + id: '0', }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -263,7 +263,7 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: {}, - pending: [{ path: [], label: 'DeferQuery' }], + pending: [{ id: '0', path: [], label: 'DeferQuery' }], hasNext: true, }, { @@ -274,10 +274,10 @@ describe('Execute: defer directive', () => { id: '1', }, }, - path: [], + id: '0', }, ], - completed: [{ path: [], label: 'DeferQuery' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -305,7 +305,7 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: {}, - pending: [{ path: [], label: 'DeferQuery' }], + pending: [{ id: '0', path: [], label: 'DeferQuery' }], hasNext: true, }, { @@ -323,10 +323,10 @@ describe('Execute: defer directive', () => { path: ['hero', 'name'], }, ], - path: [], + id: '0', }, ], - completed: [{ path: [], label: 'DeferQuery' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -356,8 +356,8 @@ describe('Execute: defer directive', () => { hero: {}, }, pending: [ - { path: ['hero'], label: 'DeferTop' }, - { path: ['hero'], label: 'DeferNested' }, + { id: '0', path: ['hero'], label: 'DeferTop' }, + { id: '1', path: ['hero'], label: 'DeferNested' }, ], hasNext: true, }, @@ -367,19 +367,16 @@ describe('Execute: defer directive', () => { data: { id: '1', }, - path: ['hero'], + id: '0', }, { data: { friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }], }, - path: ['hero'], + id: '1', }, ], - completed: [ - { path: ['hero'], label: 'DeferTop' }, - { path: ['hero'], label: 'DeferNested' }, - ], + completed: [{ id: '0' }, { id: '1' }], hasNext: false, }, ]); @@ -404,11 +401,11 @@ describe('Execute: defer directive', () => { name: 'Luke', }, }, - pending: [{ path: ['hero'], label: 'DeferTop' }], + pending: [{ id: '0', path: ['hero'], label: 'DeferTop' }], hasNext: true, }, { - completed: [{ path: ['hero'], label: 'DeferTop' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -433,11 +430,11 @@ describe('Execute: defer directive', () => { name: 'Luke', }, }, - pending: [{ path: ['hero'], label: 'DeferTop' }], + pending: [{ id: '0', path: ['hero'], label: 'DeferTop' }], hasNext: true, }, { - completed: [{ path: ['hero'], label: 'DeferTop' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -459,12 +456,12 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { id: '1' } }, - pending: [{ path: ['hero'], label: 'InlineDeferred' }], + pending: [{ id: '0', path: ['hero'], label: 'InlineDeferred' }], hasNext: true, }, { - incremental: [{ data: { name: 'Luke' }, path: ['hero'] }], - completed: [{ path: ['hero'], label: 'InlineDeferred' }], + incremental: [{ data: { name: 'Luke' }, id: '0' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -489,11 +486,11 @@ describe('Execute: defer directive', () => { data: { hero: {}, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -519,8 +516,8 @@ describe('Execute: defer directive', () => { hero: {}, }, pending: [ - { path: ['hero'], label: 'DeferID' }, - { path: ['hero'], label: 'DeferName' }, + { id: '0', path: ['hero'], label: 'DeferID' }, + { id: '1', path: ['hero'], label: 'DeferName' }, ], hasNext: true, }, @@ -530,19 +527,16 @@ describe('Execute: defer directive', () => { data: { id: '1', }, - path: ['hero'], + id: '0', }, { data: { name: 'Luke', }, - path: ['hero'], + id: '1', }, ], - completed: [ - { path: ['hero'], label: 'DeferID' }, - { path: ['hero'], label: 'DeferName' }, - ], + completed: [{ id: '0' }, { id: '1' }], hasNext: false, }, ]); @@ -568,8 +562,8 @@ describe('Execute: defer directive', () => { { data: {}, pending: [ - { path: [], label: 'DeferID' }, - { path: [], label: 'DeferName' }, + { id: '0', path: [], label: 'DeferID' }, + { id: '1', path: [], label: 'DeferName' }, ], hasNext: true, }, @@ -577,21 +571,20 @@ describe('Execute: defer directive', () => { incremental: [ { data: { hero: {} }, - path: [], + id: '0', }, { data: { id: '1' }, - path: ['hero'], + id: '0', + subPath: ['hero'], }, { data: { name: 'Luke' }, - path: ['hero'], + id: '1', + subPath: ['hero'], }, ], - completed: [ - { path: [], label: 'DeferID' }, - { path: [], label: 'DeferName' }, - ], + completed: [{ id: '0' }, { id: '1' }], hasNext: false, }, ]); @@ -622,8 +615,8 @@ describe('Execute: defer directive', () => { { data: {}, pending: [ - { path: [], label: 'DeferID' }, - { path: [], label: 'DeferName' }, + { id: '0', path: [], label: 'DeferID' }, + { id: '1', path: [], label: 'DeferName' }, ], hasNext: true, }, @@ -631,21 +624,20 @@ describe('Execute: defer directive', () => { incremental: [ { data: { hero: {} }, - path: [], + id: '0', }, { data: { id: '1' }, - path: ['hero'], + id: '0', + subPath: ['hero'], }, { data: { name: 'Luke' }, - path: ['hero'], + id: '1', + subPath: ['hero'], }, ], - completed: [ - { path: [], label: 'DeferID' }, - { path: [], label: 'DeferName' }, - ], + completed: [{ id: '0' }, { id: '1' }], hasNext: false, }, ]); @@ -673,8 +665,8 @@ describe('Execute: defer directive', () => { hero: {}, }, pending: [ - { path: [], label: 'DeferName' }, - { path: ['hero'], label: 'DeferID' }, + { id: '0', path: [], label: 'DeferName' }, + { id: '1', path: ['hero'], label: 'DeferID' }, ], hasNext: true, }, @@ -684,19 +676,17 @@ describe('Execute: defer directive', () => { data: { id: '1', }, - path: ['hero'], + id: '1', }, { data: { name: 'Luke', }, - path: ['hero'], + id: '0', + subPath: ['hero'], }, ], - completed: [ - { path: ['hero'], label: 'DeferID' }, - { path: [], label: 'DeferName' }, - ], + completed: [{ id: '1' }, { id: '0' }], hasNext: false, }, ]); @@ -719,11 +709,11 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: {}, - pending: [{ path: [], label: 'DeferName' }], + pending: [{ id: '0', path: [], label: 'DeferName' }], hasNext: true, }, { - pending: [{ path: ['hero'], label: 'DeferID' }], + pending: [{ id: '1', path: ['hero'], label: 'DeferID' }], incremental: [ { data: { @@ -731,10 +721,10 @@ describe('Execute: defer directive', () => { name: 'Luke', }, }, - path: [], + id: '0', }, ], - completed: [{ path: [], label: 'DeferName' }], + completed: [{ id: '0' }], hasNext: true, }, { @@ -743,10 +733,10 @@ describe('Execute: defer directive', () => { data: { id: '1', }, - path: ['hero'], + id: '1', }, ], - completed: [{ path: ['hero'], label: 'DeferID' }], + completed: [{ id: '1' }], hasNext: false, }, ]); @@ -784,40 +774,40 @@ describe('Execute: defer directive', () => { { data: { hero: { friends: [{}, {}, {}] } }, pending: [ - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, - { path: ['hero', 'friends', 2] }, - { path: ['hero', 'friends', 2] }, - { path: ['hero', 'friends', 2] }, + { id: '0', path: ['hero', 'friends', 0] }, + { id: '1', path: ['hero', 'friends', 0] }, + { id: '2', path: ['hero', 'friends', 0] }, + { id: '3', path: ['hero', 'friends', 0] }, + { id: '4', path: ['hero', 'friends', 1] }, + { id: '5', path: ['hero', 'friends', 1] }, + { id: '6', path: ['hero', 'friends', 1] }, + { id: '7', path: ['hero', 'friends', 1] }, + { id: '8', path: ['hero', 'friends', 2] }, + { id: '9', path: ['hero', 'friends', 2] }, + { id: '10', path: ['hero', 'friends', 2] }, + { id: '11', path: ['hero', 'friends', 2] }, ], hasNext: true, }, { incremental: [ - { data: { id: '2', name: 'Han' }, path: ['hero', 'friends', 0] }, - { data: { id: '3', name: 'Leia' }, path: ['hero', 'friends', 1] }, - { data: { id: '4', name: 'C-3PO' }, path: ['hero', 'friends', 2] }, + { data: { id: '2', name: 'Han' }, id: '0' }, + { data: { id: '3', name: 'Leia' }, id: '4' }, + { data: { id: '4', name: 'C-3PO' }, id: '8' }, ], completed: [ - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, - { path: ['hero', 'friends', 2] }, - { path: ['hero', 'friends', 2] }, - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, + { id: '1' }, + { id: '2' }, + { id: '3' }, + { id: '5' }, + { id: '6' }, + { id: '7' }, + { id: '9' }, + { id: '10' }, + { id: '11' }, + { id: '0' }, + { id: '4' }, + { id: '8' }, ], hasNext: false, }, @@ -875,17 +865,18 @@ describe('Execute: defer directive', () => { }, }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { incremental: [ { data: { bar: 'bar' }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '0', + subPath: ['nestedObject', 'deeperObject'], }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -917,11 +908,11 @@ describe('Execute: defer directive', () => { data: { hero: {}, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }], + pending: [{ id: '1', path: ['hero', 'nestedObject', 'deeperObject'] }], incremental: [ { data: { @@ -929,10 +920,10 @@ describe('Execute: defer directive', () => { deeperObject: { foo: 'foo' }, }, }, - path: ['hero'], + id: '0', }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: true, }, { @@ -941,10 +932,10 @@ describe('Execute: defer directive', () => { data: { bar: 'bar', }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '1', }, ], - completed: [{ path: ['hero', 'nestedObject', 'deeperObject'] }], + completed: [{ id: '1' }], hasNext: false, }, ]); @@ -1001,39 +992,41 @@ describe('Execute: defer directive', () => { }, }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - pending: [{ path: ['hero', 'nestedObject'] }], + pending: [{ id: '1', path: ['hero', 'nestedObject'] }], incremental: [ { data: { bar: 'bar' }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '0', + subPath: ['nestedObject', 'deeperObject'], }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: true, }, { - pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }], + pending: [{ id: '2', path: ['hero', 'nestedObject', 'deeperObject'] }], incremental: [ { data: { baz: 'baz' }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '1', + subPath: ['deeperObject'], }, ], hasNext: true, - completed: [{ path: ['hero', 'nestedObject'] }], + completed: [{ id: '1' }], }, { incremental: [ { data: { bak: 'bak' }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '2', }, ], - completed: [{ path: ['hero', 'nestedObject', 'deeperObject'] }], + completed: [{ id: '2' }], hasNext: false, }, ]); @@ -1076,25 +1069,22 @@ describe('Execute: defer directive', () => { }, }, pending: [ - { path: ['hero'] }, - { path: ['hero', 'nestedObject', 'deeperObject'] }, + { id: '0', path: ['hero'] }, + { id: '1', path: ['hero', 'nestedObject', 'deeperObject'] }, ], hasNext: true, }, { - pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }], + pending: [{ id: '2', path: ['hero', 'nestedObject', 'deeperObject'] }], incremental: [ { data: { foo: 'foo', }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '1', }, ], - completed: [ - { path: ['hero'] }, - { path: ['hero', 'nestedObject', 'deeperObject'] }, - ], + completed: [{ id: '0' }, { id: '1' }], hasNext: true, }, { @@ -1103,10 +1093,10 @@ describe('Execute: defer directive', () => { data: { bar: 'bar', }, - path: ['hero', 'nestedObject', 'deeperObject'], + id: '2', }, ], - completed: [{ path: ['hero', 'nestedObject', 'deeperObject'] }], + completed: [{ id: '2' }], hasNext: false, }, ]); @@ -1161,21 +1151,24 @@ describe('Execute: defer directive', () => { }, }, }, - pending: [{ path: [] }, { path: ['a', 'b'] }], + pending: [ + { id: '0', path: [] }, + { id: '1', path: ['a', 'b'] }, + ], hasNext: true, }, { incremental: [ { data: { e: { f: 'f' } }, - path: ['a', 'b'], + id: '1', }, { data: { g: { h: 'h' } }, - path: [], + id: '0', }, ], - completed: [{ path: ['a', 'b'] }, { path: [] }], + completed: [{ id: '1' }, { id: '0' }], hasNext: false, }, ]); @@ -1213,23 +1206,27 @@ describe('Execute: defer directive', () => { data: { a: {}, }, - pending: [{ path: [] }, { path: ['a'] }], + pending: [ + { id: '0', path: [] }, + { id: '1', path: ['a'] }, + ], hasNext: true, }, { incremental: [ { data: { b: { c: {} } }, - path: ['a'], + id: '1', }, { data: { d: 'd' }, - path: ['a', 'b', 'c'], + id: '1', + subPath: ['b', 'c'], }, ], completed: [ { - path: [], + id: '0', errors: [ { message: @@ -1239,7 +1236,7 @@ describe('Execute: defer directive', () => { }, ], }, - { path: ['a'] }, + { id: '1' }, ], hasNext: false, }, @@ -1281,23 +1278,27 @@ describe('Execute: defer directive', () => { data: { a: {}, }, - pending: [{ path: [] }, { path: ['a'] }], + pending: [ + { id: '0', path: [] }, + { id: '1', path: ['a'] }, + ], hasNext: true, }, { incremental: [ { data: { b: { c: {} } }, - path: ['a'], + id: '1', }, { data: { d: 'd' }, - path: ['a', 'b', 'c'], + id: '0', + subPath: ['a', 'b', 'c'], }, ], completed: [ { - path: ['a'], + id: '1', errors: [ { message: @@ -1307,7 +1308,7 @@ describe('Execute: defer directive', () => { }, ], }, - { path: [] }, + { id: '0' }, ], hasNext: false, }, @@ -1357,27 +1358,31 @@ describe('Execute: defer directive', () => { data: { a: {}, }, - pending: [{ path: [] }, { path: ['a'] }], + pending: [ + { id: '0', path: [] }, + { id: '1', path: ['a'] }, + ], hasNext: true, }, { incremental: [ { data: { b: { c: {} } }, - path: ['a'], + id: '1', }, { data: { d: 'd' }, - path: ['a', 'b', 'c'], + id: '1', + subPath: ['b', 'c'], }, ], - completed: [{ path: ['a'] }], + completed: [{ id: '1' }], hasNext: true, }, { completed: [ { - path: [], + id: '0', errors: [ { message: @@ -1447,7 +1452,7 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: {}, - pending: [{ path: [] }], + pending: [{ id: '0', path: [] }], hasNext: true, }, { @@ -1464,10 +1469,10 @@ describe('Execute: defer directive', () => { path: ['hero', 'nonNullName'], }, ], - path: [], + id: '0', }, ], - completed: [{ path: [] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1496,11 +1501,11 @@ describe('Execute: defer directive', () => { friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }], }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1532,11 +1537,11 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { friends: [{ name: 'Han' }] } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1569,11 +1574,11 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { friends: [] } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1602,25 +1607,28 @@ describe('Execute: defer directive', () => { friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }], }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { incremental: [ { data: { id: '2' }, - path: ['hero', 'friends', 0], + id: '0', + subPath: ['friends', 0], }, { data: { id: '3' }, - path: ['hero', 'friends', 1], + id: '0', + subPath: ['friends', 1], }, { data: { id: '4' }, - path: ['hero', 'friends', 2], + id: '0', + subPath: ['friends', 2], }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1650,11 +1658,11 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { friends: [] } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1684,11 +1692,11 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { nestedObject: null } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1717,11 +1725,11 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { nestedObject: { name: 'foo' } } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1750,14 +1758,14 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { id: '1' } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { incremental: [ { data: { name: null }, - path: ['hero'], + id: '0', errors: [ { message: 'bad', @@ -1767,7 +1775,7 @@ describe('Execute: defer directive', () => { ], }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1793,13 +1801,13 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { id: '1' } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { completed: [ { - path: ['hero'], + id: '0', errors: [ { message: @@ -1872,13 +1880,13 @@ describe('Execute: defer directive', () => { expectJSON(result).toDeepEqual([ { data: { hero: { id: '1' } }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { completed: [ { - path: ['hero'], + id: '0', errors: [ { message: @@ -1925,35 +1933,31 @@ describe('Execute: defer directive', () => { data: { hero: { id: '1' }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { pending: [ - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, + { id: '1', path: ['hero', 'friends', 0] }, + { id: '2', path: ['hero', 'friends', 1] }, + { id: '3', path: ['hero', 'friends', 2] }, ], incremental: [ { data: { name: 'slow', friends: [{}, {}, {}] }, - path: ['hero'], + id: '0', }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: true, }, { incremental: [ - { data: { name: 'Han' }, path: ['hero', 'friends', 0] }, - { data: { name: 'Leia' }, path: ['hero', 'friends', 1] }, - { data: { name: 'C-3PO' }, path: ['hero', 'friends', 2] }, - ], - completed: [ - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, + { data: { name: 'Han' }, id: '1' }, + { data: { name: 'Leia' }, id: '2' }, + { data: { name: 'C-3PO' }, id: '3' }, ], + completed: [{ id: '1' }, { id: '2' }, { id: '3' }], hasNext: false, }, ]); @@ -1982,14 +1986,14 @@ describe('Execute: defer directive', () => { data: { hero: { id: '1' }, }, - pending: [{ path: ['hero'] }], + pending: [{ id: '0', path: ['hero'] }], hasNext: true, }, { pending: [ - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, + { id: '1', path: ['hero', 'friends', 0] }, + { id: '2', path: ['hero', 'friends', 1] }, + { id: '3', path: ['hero', 'friends', 2] }, ], incremental: [ { @@ -1997,23 +2001,19 @@ describe('Execute: defer directive', () => { name: 'Luke', friends: [{}, {}, {}], }, - path: ['hero'], + id: '0', }, ], - completed: [{ path: ['hero'] }], + completed: [{ id: '0' }], hasNext: true, }, { incremental: [ - { data: { name: 'Han' }, path: ['hero', 'friends', 0] }, - { data: { name: 'Leia' }, path: ['hero', 'friends', 1] }, - { data: { name: 'C-3PO' }, path: ['hero', 'friends', 2] }, - ], - completed: [ - { path: ['hero', 'friends', 0] }, - { path: ['hero', 'friends', 1] }, - { path: ['hero', 'friends', 2] }, + { data: { name: 'Han' }, id: '1' }, + { data: { name: 'Leia' }, id: '2' }, + { data: { name: 'C-3PO' }, id: '3' }, ], + completed: [{ id: '1' }, { id: '2' }, { id: '3' }], hasNext: false, }, ]); diff --git a/src/execution/__tests__/mutations-test.ts b/src/execution/__tests__/mutations-test.ts index 13003f7d6b..5697bf5250 100644 --- a/src/execution/__tests__/mutations-test.ts +++ b/src/execution/__tests__/mutations-test.ts @@ -237,19 +237,19 @@ describe('Execute: Handles mutation execution ordering', () => { first: {}, second: { theNumber: 2 }, }, - pending: [{ path: ['first'], label: 'defer-label' }], + pending: [{ id: '0', path: ['first'], label: 'defer-label' }], hasNext: true, }, { incremental: [ { - path: ['first'], + id: '0', data: { promiseToGetTheNumber: 2, }, }, ], - completed: [{ path: ['first'], label: 'defer-label' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -313,13 +313,13 @@ describe('Execute: Handles mutation execution ordering', () => { data: { second: { theNumber: 2 }, }, - pending: [{ path: [], label: 'defer-label' }], + pending: [{ id: '0', path: [], label: 'defer-label' }], hasNext: true, }, { incremental: [ { - path: [], + id: '0', data: { first: { theNumber: 1, @@ -327,7 +327,7 @@ describe('Execute: Handles mutation execution ordering', () => { }, }, ], - completed: [{ path: [], label: 'defer-label' }], + completed: [{ id: '0' }], hasNext: false, }, ]); diff --git a/src/execution/__tests__/stream-test.ts b/src/execution/__tests__/stream-test.ts index 12d4ddd43f..77fd5ce9e9 100644 --- a/src/execution/__tests__/stream-test.ts +++ b/src/execution/__tests__/stream-test.ts @@ -142,16 +142,16 @@ describe('Execute: stream directive', () => { data: { scalarList: ['apple'], }, - pending: [{ path: ['scalarList'] }], + pending: [{ id: '0', path: ['scalarList'] }], hasNext: true, }, { - incremental: [{ items: ['banana'], path: ['scalarList'] }], + incremental: [{ items: ['banana'], id: '0' }], hasNext: true, }, { - incremental: [{ items: ['coconut'], path: ['scalarList'] }], - completed: [{ path: ['scalarList'] }], + incremental: [{ items: ['coconut'], id: '0' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -166,20 +166,20 @@ describe('Execute: stream directive', () => { data: { scalarList: [], }, - pending: [{ path: ['scalarList'] }], + pending: [{ id: '0', path: ['scalarList'] }], hasNext: true, }, { - incremental: [{ items: ['apple'], path: ['scalarList'] }], + incremental: [{ items: ['apple'], id: '0' }], hasNext: true, }, { - incremental: [{ items: ['banana'], path: ['scalarList'] }], + incremental: [{ items: ['banana'], id: '0' }], hasNext: true, }, { - incremental: [{ items: ['coconut'], path: ['scalarList'] }], - completed: [{ path: ['scalarList'] }], + incremental: [{ items: ['coconut'], id: '0' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -219,14 +219,14 @@ describe('Execute: stream directive', () => { data: { scalarList: ['apple'], }, - pending: [{ path: ['scalarList'], label: 'scalar-stream' }], + pending: [{ id: '0', path: ['scalarList'], label: 'scalar-stream' }], hasNext: true, }, { incremental: [ { items: ['banana'], - path: ['scalarList'], + id: '0', }, ], hasNext: true, @@ -235,10 +235,10 @@ describe('Execute: stream directive', () => { incremental: [ { items: ['coconut'], - path: ['scalarList'], + id: '0', }, ], - completed: [{ path: ['scalarList'], label: 'scalar-stream' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -264,12 +264,12 @@ describe('Execute: stream directive', () => { expectJSON(result).toDeepEqual([ { data: { scalarList: ['apple', 'banana'] }, - pending: [{ path: ['scalarList'] }], + pending: [{ id: '0', path: ['scalarList'] }], hasNext: true, }, { - incremental: [{ items: ['coconut'], path: ['scalarList'] }], - completed: [{ path: ['scalarList'] }], + incremental: [{ items: ['coconut'], id: '0' }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -288,14 +288,14 @@ describe('Execute: stream directive', () => { data: { scalarListList: [['apple', 'apple', 'apple']], }, - pending: [{ path: ['scalarListList'] }], + pending: [{ id: '0', path: ['scalarListList'] }], hasNext: true, }, { incremental: [ { items: [['banana', 'banana', 'banana']], - path: ['scalarListList'], + id: '0', }, ], hasNext: true, @@ -304,10 +304,10 @@ describe('Execute: stream directive', () => { incremental: [ { items: [['coconut', 'coconut', 'coconut']], - path: ['scalarListList'], + id: '0', }, ], - completed: [{ path: ['scalarListList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -338,7 +338,7 @@ describe('Execute: stream directive', () => { }, ], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { @@ -350,10 +350,10 @@ describe('Execute: stream directive', () => { id: '3', }, ], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -375,14 +375,14 @@ describe('Execute: stream directive', () => { data: { friendList: [], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [{ name: 'Luke', id: '1' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, @@ -391,7 +391,7 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Han', id: '2' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, @@ -400,10 +400,10 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Leia', id: '3' }], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -438,7 +438,7 @@ describe('Execute: stream directive', () => { }, ], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { @@ -450,10 +450,10 @@ describe('Execute: stream directive', () => { id: '3', }, ], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -488,17 +488,17 @@ describe('Execute: stream directive', () => { data: { friendList: [{ name: 'Luke', id: '1' }, null], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [{ name: 'Leia', id: '3' }], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -526,14 +526,14 @@ describe('Execute: stream directive', () => { data: { friendList: [{ name: 'Luke', id: '1' }], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [null], - path: ['friendList'], + id: '0', errors: [ { message: 'bad', @@ -549,10 +549,10 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Leia', id: '3' }], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -578,14 +578,14 @@ describe('Execute: stream directive', () => { data: { friendList: [], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [{ name: 'Luke', id: '1' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, @@ -594,7 +594,7 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Han', id: '2' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, @@ -603,13 +603,13 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Leia', id: '3' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, }, { - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -638,20 +638,20 @@ describe('Execute: stream directive', () => { { name: 'Han', id: '2' }, ], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [{ name: 'Leia', id: '3' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, }, { - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -708,7 +708,7 @@ describe('Execute: stream directive', () => { { name: 'Han', id: '2' }, ], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, }, @@ -718,7 +718,7 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Leia', id: '3' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, @@ -727,7 +727,7 @@ describe('Execute: stream directive', () => { { done: false, value: { - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, }, @@ -782,13 +782,13 @@ describe('Execute: stream directive', () => { data: { friendList: [{ name: 'Luke', id: '1' }], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { completed: [ { - path: ['friendList'], + id: '0', errors: [ { message: 'bad', @@ -819,13 +819,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ name: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: @@ -866,13 +866,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ name: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: @@ -901,14 +901,14 @@ describe('Execute: stream directive', () => { data: { scalarList: ['Luke'], }, - pending: [{ path: ['scalarList'] }], + pending: [{ id: '0', path: ['scalarList'] }], hasNext: true, }, { incremental: [ { items: [null], - path: ['scalarList'], + id: '0', errors: [ { message: 'String cannot represent value: {}', @@ -918,7 +918,7 @@ describe('Execute: stream directive', () => { ], }, ], - completed: [{ path: ['scalarList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -945,14 +945,14 @@ describe('Execute: stream directive', () => { data: { friendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [null], - path: ['friendList'], + id: '0', errors: [ { message: 'Oops', @@ -968,10 +968,10 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ nonNullName: 'Han' }], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -996,14 +996,14 @@ describe('Execute: stream directive', () => { data: { friendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [null], - path: ['friendList'], + id: '0', errors: [ { message: 'Oops', @@ -1019,10 +1019,10 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ nonNullName: 'Han' }], - path: ['friendList'], + id: '0', }, ], - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1049,13 +1049,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: 'Oops', @@ -1089,13 +1089,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: 'Oops', @@ -1131,14 +1131,14 @@ describe('Execute: stream directive', () => { data: { friendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [null], - path: ['friendList'], + id: '0', errors: [ { message: 'Oops', @@ -1154,13 +1154,13 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ nonNullName: 'Han' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, }, { - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1189,13 +1189,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: 'Oops', @@ -1257,13 +1257,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: 'Oops', @@ -1335,13 +1335,13 @@ describe('Execute: stream directive', () => { data: { nonNullFriendList: [{ nonNullName: 'Luke' }], }, - pending: [{ path: ['nonNullFriendList'] }], + pending: [{ id: '0', path: ['nonNullFriendList'] }], hasNext: true, }, { completed: [ { - path: ['nonNullFriendList'], + id: '0', errors: [ { message: 'Oops', @@ -1452,8 +1452,8 @@ describe('Execute: stream directive', () => { nestedObject: { nestedFriendList: [] }, }, pending: [ - { path: ['otherNestedObject'] }, - { path: ['nestedObject', 'nestedFriendList'] }, + { id: '0', path: ['otherNestedObject'] }, + { id: '1', path: ['nestedObject', 'nestedFriendList'] }, ], hasNext: true, }, @@ -1461,7 +1461,7 @@ describe('Execute: stream directive', () => { incremental: [ { data: { scalarField: null }, - path: ['otherNestedObject'], + id: '0', errors: [ { message: 'Oops', @@ -1472,14 +1472,14 @@ describe('Execute: stream directive', () => { }, { items: [{ name: 'Luke' }], - path: ['nestedObject', 'nestedFriendList'], + id: '1', }, ], - completed: [{ path: ['otherNestedObject'] }], + completed: [{ id: '0' }], hasNext: true, }, { - completed: [{ path: ['nestedObject', 'nestedFriendList'] }], + completed: [{ id: '1' }], hasNext: false, }, ]); @@ -1514,7 +1514,7 @@ describe('Execute: stream directive', () => { data: { nestedObject: {}, }, - pending: [{ path: ['nestedObject'] }], + pending: [{ id: '0', path: ['nestedObject'] }], hasNext: true, }, { @@ -1523,7 +1523,7 @@ describe('Execute: stream directive', () => { data: { deeperNestedObject: null, }, - path: ['nestedObject'], + id: '0', errors: [ { message: @@ -1538,7 +1538,7 @@ describe('Execute: stream directive', () => { ], }, ], - completed: [{ path: ['nestedObject'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1567,14 +1567,14 @@ describe('Execute: stream directive', () => { data: { friendList: [], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [null], - path: ['friendList'], + id: '0', errors: [ { message: @@ -1588,7 +1588,7 @@ describe('Execute: stream directive', () => { hasNext: true, }, { - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1658,7 +1658,7 @@ describe('Execute: stream directive', () => { data: { nestedObject: {}, }, - pending: [{ path: ['nestedObject'] }], + pending: [{ id: '0', path: ['nestedObject'] }], hasNext: true, }); @@ -1671,7 +1671,7 @@ describe('Execute: stream directive', () => { data: { deeperNestedObject: null, }, - path: ['nestedObject'], + id: '0', errors: [ { message: @@ -1686,7 +1686,7 @@ describe('Execute: stream directive', () => { ], }, ], - completed: [{ path: ['nestedObject'] }], + completed: [{ id: '0' }], hasNext: false, }, }); @@ -1720,14 +1720,14 @@ describe('Execute: stream directive', () => { data: { friendList: [{ id: '1', name: 'Luke' }], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }, { incremental: [ { items: [{ id: '2', name: 'Han' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, @@ -1736,13 +1736,13 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ id: '3', name: 'Leia' }], - path: ['friendList'], + id: '0', }, ], hasNext: true, }, { - completed: [{ path: ['friendList'] }], + completed: [{ id: '0' }], hasNext: false, }, ]); @@ -1781,8 +1781,8 @@ describe('Execute: stream directive', () => { }, }, pending: [ - { path: ['nestedObject'] }, - { path: ['nestedObject', 'nestedFriendList'] }, + { id: '0', path: ['nestedObject'] }, + { id: '1', path: ['nestedObject', 'nestedFriendList'] }, ], hasNext: true, }, @@ -1790,23 +1790,23 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ id: '1', name: 'Luke' }], - path: ['nestedObject', 'nestedFriendList'], + id: '1', }, ], - completed: [{ path: ['nestedObject'] }], + completed: [{ id: '0' }], hasNext: true, }, { incremental: [ { items: [{ id: '2', name: 'Han' }], - path: ['nestedObject', 'nestedFriendList'], + id: '1', }, ], hasNext: true, }, { - completed: [{ path: ['nestedObject', 'nestedFriendList'] }], + completed: [{ id: '1' }], hasNext: false, }, ]); @@ -1848,7 +1848,7 @@ describe('Execute: stream directive', () => { data: { nestedObject: {}, }, - pending: [{ path: ['nestedObject'] }], + pending: [{ id: '0', path: ['nestedObject'] }], hasNext: true, }); @@ -1857,14 +1857,14 @@ describe('Execute: stream directive', () => { const result2 = await result2Promise; expectJSON(result2).toDeepEqual({ value: { - pending: [{ path: ['nestedObject', 'nestedFriendList'] }], + pending: [{ id: '1', path: ['nestedObject', 'nestedFriendList'] }], incremental: [ { data: { scalarField: 'slow', nestedFriendList: [] }, - path: ['nestedObject'], + id: '0', }, ], - completed: [{ path: ['nestedObject'] }], + completed: [{ id: '0' }], hasNext: true, }, done: false, @@ -1875,7 +1875,7 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Luke' }], - path: ['nestedObject', 'nestedFriendList'], + id: '1', }, ], hasNext: true, @@ -1888,7 +1888,7 @@ describe('Execute: stream directive', () => { incremental: [ { items: [{ name: 'Han' }], - path: ['nestedObject', 'nestedFriendList'], + id: '1', }, ], hasNext: true, @@ -1898,7 +1898,7 @@ describe('Execute: stream directive', () => { const result5 = await iterator.next(); expectJSON(result5).toDeepEqual({ value: { - completed: [{ path: ['nestedObject', 'nestedFriendList'] }], + completed: [{ id: '1' }], hasNext: false, }, done: false, @@ -1952,8 +1952,8 @@ describe('Execute: stream directive', () => { friendList: [{ id: '1' }], }, pending: [ - { path: ['friendList', 0], label: 'DeferName' }, - { path: ['friendList'], label: 'stream-label' }, + { id: '0', path: ['friendList', 0], label: 'DeferName' }, + { id: '1', path: ['friendList'], label: 'stream-label' }, ], hasNext: true, }); @@ -1963,18 +1963,18 @@ describe('Execute: stream directive', () => { const result2 = await result2Promise; expectJSON(result2).toDeepEqual({ value: { - pending: [{ path: ['friendList', 1], label: 'DeferName' }], + pending: [{ id: '2', path: ['friendList', 1], label: 'DeferName' }], incremental: [ { data: { name: 'Luke' }, - path: ['friendList', 0], + id: '0', }, { items: [{ id: '2' }], - path: ['friendList'], + id: '1', }, ], - completed: [{ path: ['friendList', 0], label: 'DeferName' }], + completed: [{ id: '0' }], hasNext: true, }, done: false, @@ -1985,7 +1985,7 @@ describe('Execute: stream directive', () => { const result3 = await result3Promise; expectJSON(result3).toDeepEqual({ value: { - completed: [{ path: ['friendList'], label: 'stream-label' }], + completed: [{ id: '1' }], hasNext: true, }, done: false, @@ -1996,10 +1996,10 @@ describe('Execute: stream directive', () => { incremental: [ { data: { name: 'Han' }, - path: ['friendList', 1], + id: '2', }, ], - completed: [{ path: ['friendList', 1], label: 'DeferName' }], + completed: [{ id: '2' }], hasNext: false, }, done: false, @@ -2053,8 +2053,8 @@ describe('Execute: stream directive', () => { friendList: [{ id: '1' }], }, pending: [ - { path: ['friendList', 0], label: 'DeferName' }, - { path: ['friendList'], label: 'stream-label' }, + { id: '0', path: ['friendList', 0], label: 'DeferName' }, + { id: '1', path: ['friendList'], label: 'stream-label' }, ], hasNext: true, }); @@ -2064,18 +2064,18 @@ describe('Execute: stream directive', () => { const result2 = await result2Promise; expectJSON(result2).toDeepEqual({ value: { - pending: [{ path: ['friendList', 1], label: 'DeferName' }], + pending: [{ id: '2', path: ['friendList', 1], label: 'DeferName' }], incremental: [ { data: { name: 'Luke' }, - path: ['friendList', 0], + id: '0', }, { items: [{ id: '2' }], - path: ['friendList'], + id: '1', }, ], - completed: [{ path: ['friendList', 0], label: 'DeferName' }], + completed: [{ id: '0' }], hasNext: true, }, done: false, @@ -2087,10 +2087,10 @@ describe('Execute: stream directive', () => { incremental: [ { data: { name: 'Han' }, - path: ['friendList', 1], + id: '2', }, ], - completed: [{ path: ['friendList', 1], label: 'DeferName' }], + completed: [{ id: '2' }], hasNext: true, }, done: false, @@ -2100,7 +2100,7 @@ describe('Execute: stream directive', () => { const result4 = await result4Promise; expectJSON(result4).toDeepEqual({ value: { - completed: [{ path: ['friendList'], label: 'stream-label' }], + completed: [{ id: '1' }], hasNext: false, }, done: false, @@ -2160,7 +2160,10 @@ describe('Execute: stream directive', () => { }, ], }, - pending: [{ path: ['friendList', 0] }, { path: ['friendList'] }], + pending: [ + { id: '0', path: ['friendList', 0] }, + { id: '1', path: ['friendList'] }, + ], hasNext: true, }); const returnPromise = iterator.return(); @@ -2216,7 +2219,7 @@ describe('Execute: stream directive', () => { }, ], }, - pending: [{ path: ['friendList'] }], + pending: [{ id: '0', path: ['friendList'] }], hasNext: true, }); @@ -2276,7 +2279,10 @@ describe('Execute: stream directive', () => { }, ], }, - pending: [{ path: ['friendList', 0] }, { path: ['friendList'] }], + pending: [ + { id: '0', path: ['friendList', 0] }, + { id: '1', path: ['friendList'] }, + ], hasNext: true, });