Skip to content

Commit 7b87fef

Browse files
committed
add pending notifications
1 parent 1cd3dd0 commit 7b87fef

File tree

4 files changed

+197
-11
lines changed

4 files changed

+197
-11
lines changed

src/execution/__tests__/defer-test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ describe('Execute: defer directive', () => {
186186
id: '1',
187187
},
188188
},
189+
pending: [{ path: ['hero'] }],
189190
hasNext: true,
190191
},
191192
{
@@ -241,6 +242,7 @@ describe('Execute: defer directive', () => {
241242
expectJSON(result).toDeepEqual([
242243
{
243244
data: { hero: { id: '1' } },
245+
pending: [{ path: ['hero'] }],
244246
hasNext: true,
245247
},
246248
{
@@ -271,6 +273,7 @@ describe('Execute: defer directive', () => {
271273
expectJSON(result).toDeepEqual([
272274
{
273275
data: {},
276+
pending: [{ path: [], label: 'DeferQuery' }],
274277
hasNext: true,
275278
},
276279
{
@@ -312,6 +315,7 @@ describe('Execute: defer directive', () => {
312315
expectJSON(result).toDeepEqual([
313316
{
314317
data: {},
318+
pending: [{ path: [], label: 'DeferQuery' }],
315319
hasNext: true,
316320
},
317321
{
@@ -361,6 +365,10 @@ describe('Execute: defer directive', () => {
361365
data: {
362366
hero: {},
363367
},
368+
pending: [
369+
{ path: ['hero'], label: 'DeferTop' },
370+
{ path: ['hero'], label: 'DeferNested' },
371+
],
364372
hasNext: true,
365373
},
366374
{
@@ -406,6 +414,7 @@ describe('Execute: defer directive', () => {
406414
name: 'Luke',
407415
},
408416
},
417+
pending: [{ path: ['hero'], label: 'DeferTop' }],
409418
hasNext: true,
410419
},
411420
{
@@ -434,6 +443,7 @@ describe('Execute: defer directive', () => {
434443
name: 'Luke',
435444
},
436445
},
446+
pending: [{ path: ['hero'], label: 'DeferTop' }],
437447
hasNext: true,
438448
},
439449
{
@@ -459,6 +469,7 @@ describe('Execute: defer directive', () => {
459469
expectJSON(result).toDeepEqual([
460470
{
461471
data: { hero: { id: '1' } },
472+
pending: [{ path: ['hero'], label: 'InlineDeferred' }],
462473
hasNext: true,
463474
},
464475
{
@@ -488,6 +499,7 @@ describe('Execute: defer directive', () => {
488499
data: {
489500
hero: {},
490501
},
502+
pending: [{ path: ['hero'] }],
491503
hasNext: true,
492504
},
493505
{
@@ -516,6 +528,10 @@ describe('Execute: defer directive', () => {
516528
data: {
517529
hero: {},
518530
},
531+
pending: [
532+
{ path: ['hero'], label: 'DeferID' },
533+
{ path: ['hero'], label: 'DeferName' },
534+
],
519535
hasNext: true,
520536
},
521537
{
@@ -561,6 +577,10 @@ describe('Execute: defer directive', () => {
561577
expectJSON(result).toDeepEqual([
562578
{
563579
data: {},
580+
pending: [
581+
{ path: [], label: 'DeferID' },
582+
{ path: [], label: 'DeferName' },
583+
],
564584
hasNext: true,
565585
},
566586
{
@@ -658,6 +678,10 @@ describe('Execute: defer directive', () => {
658678
data: {
659679
hero: {},
660680
},
681+
pending: [
682+
{ path: [], label: 'DeferName' },
683+
{ path: ['hero'], label: 'DeferID' },
684+
],
661685
hasNext: true,
662686
},
663687
{
@@ -701,9 +725,11 @@ describe('Execute: defer directive', () => {
701725
expectJSON(result).toDeepEqual([
702726
{
703727
data: {},
728+
pending: [{ path: [], label: 'DeferName' }],
704729
hasNext: true,
705730
},
706731
{
732+
pending: [{ path: ['hero'], label: 'DeferID' }],
707733
incremental: [
708734
{
709735
data: {
@@ -763,6 +789,20 @@ describe('Execute: defer directive', () => {
763789
expectJSON(result).toDeepEqual([
764790
{
765791
data: { hero: { friends: [{}, {}, {}] } },
792+
pending: [
793+
{ path: ['hero', 'friends', 0] },
794+
{ path: ['hero', 'friends', 0] },
795+
{ path: ['hero', 'friends', 0] },
796+
{ path: ['hero', 'friends', 0] },
797+
{ path: ['hero', 'friends', 1] },
798+
{ path: ['hero', 'friends', 1] },
799+
{ path: ['hero', 'friends', 1] },
800+
{ path: ['hero', 'friends', 1] },
801+
{ path: ['hero', 'friends', 2] },
802+
{ path: ['hero', 'friends', 2] },
803+
{ path: ['hero', 'friends', 2] },
804+
{ path: ['hero', 'friends', 2] },
805+
],
766806
hasNext: true,
767807
},
768808
{
@@ -836,6 +876,7 @@ describe('Execute: defer directive', () => {
836876
},
837877
},
838878
},
879+
pending: [{ path: ['hero'] }],
839880
hasNext: true,
840881
},
841882
{
@@ -875,9 +916,11 @@ describe('Execute: defer directive', () => {
875916
data: {
876917
hero: {},
877918
},
919+
pending: [{ path: ['hero'] }],
878920
hasNext: true,
879921
},
880922
{
923+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
881924
incremental: [
882925
{
883926
data: {
@@ -951,9 +994,11 @@ describe('Execute: defer directive', () => {
951994
},
952995
},
953996
},
997+
pending: [{ path: ['hero'] }],
954998
hasNext: true,
955999
},
9561000
{
1001+
pending: [{ path: ['hero', 'nestedObject'] }],
9571002
incremental: [
9581003
{
9591004
data: { bar: 'bar' },
@@ -964,6 +1009,7 @@ describe('Execute: defer directive', () => {
9641009
hasNext: true,
9651010
},
9661011
{
1012+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
9671013
incremental: [
9681014
{
9691015
data: { baz: 'baz' },
@@ -1020,9 +1066,14 @@ describe('Execute: defer directive', () => {
10201066
},
10211067
},
10221068
},
1069+
pending: [
1070+
{ path: ['hero'] },
1071+
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1072+
],
10231073
hasNext: true,
10241074
},
10251075
{
1076+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
10261077
incremental: [
10271078
{
10281079
data: {
@@ -1093,6 +1144,7 @@ describe('Execute: defer directive', () => {
10931144
},
10941145
},
10951146
},
1147+
pending: [{ path: [] }, { path: ['a', 'b'] }],
10961148
hasNext: true,
10971149
},
10981150
{
@@ -1142,6 +1194,7 @@ describe('Execute: defer directive', () => {
11421194
data: {
11431195
a: {},
11441196
},
1197+
pending: [{ path: [] }, { path: ['a'] }],
11451198
hasNext: true,
11461199
},
11471200
{
@@ -1204,6 +1257,7 @@ describe('Execute: defer directive', () => {
12041257
data: {
12051258
a: {},
12061259
},
1260+
pending: [{ path: [] }, { path: ['a'] }],
12071261
hasNext: true,
12081262
},
12091263
{
@@ -1266,6 +1320,7 @@ describe('Execute: defer directive', () => {
12661320
data: {
12671321
a: {},
12681322
},
1323+
pending: [{ path: [] }, { path: ['a'] }],
12691324
hasNext: true,
12701325
},
12711326
{
@@ -1355,6 +1410,7 @@ describe('Execute: defer directive', () => {
13551410
expectJSON(result).toDeepEqual([
13561411
{
13571412
data: {},
1413+
pending: [{ path: [] }],
13581414
hasNext: true,
13591415
},
13601416
{
@@ -1403,6 +1459,7 @@ describe('Execute: defer directive', () => {
14031459
friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }],
14041460
},
14051461
},
1462+
pending: [{ path: ['hero'] }],
14061463
hasNext: true,
14071464
},
14081465
{
@@ -1438,6 +1495,7 @@ describe('Execute: defer directive', () => {
14381495
expectJSON(result).toDeepEqual([
14391496
{
14401497
data: { hero: { friends: [{ name: 'Han' }] } },
1498+
pending: [{ path: ['hero'] }],
14411499
hasNext: true,
14421500
},
14431501
{
@@ -1474,6 +1532,7 @@ describe('Execute: defer directive', () => {
14741532
expectJSON(result).toDeepEqual([
14751533
{
14761534
data: { hero: { friends: [] } },
1535+
pending: [{ path: ['hero'] }],
14771536
hasNext: true,
14781537
},
14791538
{
@@ -1506,6 +1565,7 @@ describe('Execute: defer directive', () => {
15061565
friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }],
15071566
},
15081567
},
1568+
pending: [{ path: ['hero'] }],
15091569
hasNext: true,
15101570
},
15111571
{
@@ -1553,6 +1613,7 @@ describe('Execute: defer directive', () => {
15531613
expectJSON(result).toDeepEqual([
15541614
{
15551615
data: { hero: { friends: [] } },
1616+
pending: [{ path: ['hero'] }],
15561617
hasNext: true,
15571618
},
15581619
{
@@ -1586,6 +1647,7 @@ describe('Execute: defer directive', () => {
15861647
expectJSON(result).toDeepEqual([
15871648
{
15881649
data: { hero: { nestedObject: null } },
1650+
pending: [{ path: ['hero'] }],
15891651
hasNext: true,
15901652
},
15911653
{
@@ -1619,6 +1681,7 @@ describe('Execute: defer directive', () => {
16191681
expectJSON(result).toDeepEqual([
16201682
{
16211683
data: { hero: { nestedObject: { name: 'foo' } } },
1684+
pending: [{ path: ['hero'] }],
16221685
hasNext: true,
16231686
},
16241687
{
@@ -1651,6 +1714,7 @@ describe('Execute: defer directive', () => {
16511714
expectJSON(result).toDeepEqual([
16521715
{
16531716
data: { hero: { id: '1' } },
1717+
pending: [{ path: ['hero'] }],
16541718
hasNext: true,
16551719
},
16561720
{
@@ -1693,6 +1757,7 @@ describe('Execute: defer directive', () => {
16931757
expectJSON(result).toDeepEqual([
16941758
{
16951759
data: { hero: { id: '1' } },
1760+
pending: [{ path: ['hero'] }],
16961761
hasNext: true,
16971762
},
16981763
{
@@ -1771,6 +1836,7 @@ describe('Execute: defer directive', () => {
17711836
expectJSON(result).toDeepEqual([
17721837
{
17731838
data: { hero: { id: '1' } },
1839+
pending: [{ path: ['hero'] }],
17741840
hasNext: true,
17751841
},
17761842
{
@@ -1823,9 +1889,15 @@ describe('Execute: defer directive', () => {
18231889
data: {
18241890
hero: { id: '1' },
18251891
},
1892+
pending: [{ path: ['hero'] }],
18261893
hasNext: true,
18271894
},
18281895
{
1896+
pending: [
1897+
{ path: ['hero', 'friends', 0] },
1898+
{ path: ['hero', 'friends', 1] },
1899+
{ path: ['hero', 'friends', 2] },
1900+
],
18291901
incremental: [
18301902
{
18311903
data: { name: 'slow', friends: [{}, {}, {}] },
@@ -1874,9 +1946,15 @@ describe('Execute: defer directive', () => {
18741946
data: {
18751947
hero: { id: '1' },
18761948
},
1949+
pending: [{ path: ['hero'] }],
18771950
hasNext: true,
18781951
},
18791952
{
1953+
pending: [
1954+
{ path: ['hero', 'friends', 0] },
1955+
{ path: ['hero', 'friends', 1] },
1956+
{ path: ['hero', 'friends', 2] },
1957+
],
18801958
incremental: [
18811959
{
18821960
data: {

src/execution/__tests__/mutations-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ describe('Execute: Handles mutation execution ordering', () => {
237237
first: {},
238238
second: { theNumber: 2 },
239239
},
240+
pending: [{ path: ['first'], label: 'defer-label' }],
240241
hasNext: true,
241242
},
242243
{
@@ -312,6 +313,7 @@ describe('Execute: Handles mutation execution ordering', () => {
312313
data: {
313314
second: { theNumber: 2 },
314315
},
316+
pending: [{ path: [], label: 'defer-label' }],
315317
hasNext: true,
316318
},
317319
{

0 commit comments

Comments
 (0)