Skip to content

Commit ae56632

Browse files
committed
add pending notifications
1 parent 1cd3dd0 commit ae56632

File tree

4 files changed

+201
-11
lines changed

4 files changed

+201
-11
lines changed

src/execution/__tests__/defer-test.ts

Lines changed: 82 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
{
@@ -611,6 +631,10 @@ describe('Execute: defer directive', () => {
611631
expectJSON(result).toDeepEqual([
612632
{
613633
data: {},
634+
pending: [
635+
{ path: [], label: 'DeferID' },
636+
{ path: [], label: 'DeferName' },
637+
],
614638
hasNext: true,
615639
},
616640
{
@@ -658,6 +682,10 @@ describe('Execute: defer directive', () => {
658682
data: {
659683
hero: {},
660684
},
685+
pending: [
686+
{ path: [], label: 'DeferName' },
687+
{ path: ['hero'], label: 'DeferID' },
688+
],
661689
hasNext: true,
662690
},
663691
{
@@ -701,9 +729,11 @@ describe('Execute: defer directive', () => {
701729
expectJSON(result).toDeepEqual([
702730
{
703731
data: {},
732+
pending: [{ path: [], label: 'DeferName' }],
704733
hasNext: true,
705734
},
706735
{
736+
pending: [{ path: ['hero'], label: 'DeferID' }],
707737
incremental: [
708738
{
709739
data: {
@@ -763,6 +793,20 @@ describe('Execute: defer directive', () => {
763793
expectJSON(result).toDeepEqual([
764794
{
765795
data: { hero: { friends: [{}, {}, {}] } },
796+
pending: [
797+
{ path: ['hero', 'friends', 0] },
798+
{ path: ['hero', 'friends', 0] },
799+
{ path: ['hero', 'friends', 0] },
800+
{ path: ['hero', 'friends', 0] },
801+
{ path: ['hero', 'friends', 1] },
802+
{ path: ['hero', 'friends', 1] },
803+
{ path: ['hero', 'friends', 1] },
804+
{ path: ['hero', 'friends', 1] },
805+
{ path: ['hero', 'friends', 2] },
806+
{ path: ['hero', 'friends', 2] },
807+
{ path: ['hero', 'friends', 2] },
808+
{ path: ['hero', 'friends', 2] },
809+
],
766810
hasNext: true,
767811
},
768812
{
@@ -836,6 +880,7 @@ describe('Execute: defer directive', () => {
836880
},
837881
},
838882
},
883+
pending: [{ path: ['hero'] }],
839884
hasNext: true,
840885
},
841886
{
@@ -875,9 +920,11 @@ describe('Execute: defer directive', () => {
875920
data: {
876921
hero: {},
877922
},
923+
pending: [{ path: ['hero'] }],
878924
hasNext: true,
879925
},
880926
{
927+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
881928
incremental: [
882929
{
883930
data: {
@@ -951,9 +998,11 @@ describe('Execute: defer directive', () => {
951998
},
952999
},
9531000
},
1001+
pending: [{ path: ['hero'] }],
9541002
hasNext: true,
9551003
},
9561004
{
1005+
pending: [{ path: ['hero', 'nestedObject'] }],
9571006
incremental: [
9581007
{
9591008
data: { bar: 'bar' },
@@ -964,6 +1013,7 @@ describe('Execute: defer directive', () => {
9641013
hasNext: true,
9651014
},
9661015
{
1016+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
9671017
incremental: [
9681018
{
9691019
data: { baz: 'baz' },
@@ -1020,9 +1070,14 @@ describe('Execute: defer directive', () => {
10201070
},
10211071
},
10221072
},
1073+
pending: [
1074+
{ path: ['hero'] },
1075+
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1076+
],
10231077
hasNext: true,
10241078
},
10251079
{
1080+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
10261081
incremental: [
10271082
{
10281083
data: {
@@ -1093,6 +1148,7 @@ describe('Execute: defer directive', () => {
10931148
},
10941149
},
10951150
},
1151+
pending: [{ path: [] }, { path: ['a', 'b'] }],
10961152
hasNext: true,
10971153
},
10981154
{
@@ -1142,6 +1198,7 @@ describe('Execute: defer directive', () => {
11421198
data: {
11431199
a: {},
11441200
},
1201+
pending: [{ path: [] }, { path: ['a'] }],
11451202
hasNext: true,
11461203
},
11471204
{
@@ -1204,6 +1261,7 @@ describe('Execute: defer directive', () => {
12041261
data: {
12051262
a: {},
12061263
},
1264+
pending: [{ path: [] }, { path: ['a'] }],
12071265
hasNext: true,
12081266
},
12091267
{
@@ -1266,6 +1324,7 @@ describe('Execute: defer directive', () => {
12661324
data: {
12671325
a: {},
12681326
},
1327+
pending: [{ path: [] }, { path: ['a'] }],
12691328
hasNext: true,
12701329
},
12711330
{
@@ -1355,6 +1414,7 @@ describe('Execute: defer directive', () => {
13551414
expectJSON(result).toDeepEqual([
13561415
{
13571416
data: {},
1417+
pending: [{ path: [] }],
13581418
hasNext: true,
13591419
},
13601420
{
@@ -1403,6 +1463,7 @@ describe('Execute: defer directive', () => {
14031463
friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }],
14041464
},
14051465
},
1466+
pending: [{ path: ['hero'] }],
14061467
hasNext: true,
14071468
},
14081469
{
@@ -1438,6 +1499,7 @@ describe('Execute: defer directive', () => {
14381499
expectJSON(result).toDeepEqual([
14391500
{
14401501
data: { hero: { friends: [{ name: 'Han' }] } },
1502+
pending: [{ path: ['hero'] }],
14411503
hasNext: true,
14421504
},
14431505
{
@@ -1474,6 +1536,7 @@ describe('Execute: defer directive', () => {
14741536
expectJSON(result).toDeepEqual([
14751537
{
14761538
data: { hero: { friends: [] } },
1539+
pending: [{ path: ['hero'] }],
14771540
hasNext: true,
14781541
},
14791542
{
@@ -1506,6 +1569,7 @@ describe('Execute: defer directive', () => {
15061569
friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }],
15071570
},
15081571
},
1572+
pending: [{ path: ['hero'] }],
15091573
hasNext: true,
15101574
},
15111575
{
@@ -1553,6 +1617,7 @@ describe('Execute: defer directive', () => {
15531617
expectJSON(result).toDeepEqual([
15541618
{
15551619
data: { hero: { friends: [] } },
1620+
pending: [{ path: ['hero'] }],
15561621
hasNext: true,
15571622
},
15581623
{
@@ -1586,6 +1651,7 @@ describe('Execute: defer directive', () => {
15861651
expectJSON(result).toDeepEqual([
15871652
{
15881653
data: { hero: { nestedObject: null } },
1654+
pending: [{ path: ['hero'] }],
15891655
hasNext: true,
15901656
},
15911657
{
@@ -1619,6 +1685,7 @@ describe('Execute: defer directive', () => {
16191685
expectJSON(result).toDeepEqual([
16201686
{
16211687
data: { hero: { nestedObject: { name: 'foo' } } },
1688+
pending: [{ path: ['hero'] }],
16221689
hasNext: true,
16231690
},
16241691
{
@@ -1651,6 +1718,7 @@ describe('Execute: defer directive', () => {
16511718
expectJSON(result).toDeepEqual([
16521719
{
16531720
data: { hero: { id: '1' } },
1721+
pending: [{ path: ['hero'] }],
16541722
hasNext: true,
16551723
},
16561724
{
@@ -1693,6 +1761,7 @@ describe('Execute: defer directive', () => {
16931761
expectJSON(result).toDeepEqual([
16941762
{
16951763
data: { hero: { id: '1' } },
1764+
pending: [{ path: ['hero'] }],
16961765
hasNext: true,
16971766
},
16981767
{
@@ -1771,6 +1840,7 @@ describe('Execute: defer directive', () => {
17711840
expectJSON(result).toDeepEqual([
17721841
{
17731842
data: { hero: { id: '1' } },
1843+
pending: [{ path: ['hero'] }],
17741844
hasNext: true,
17751845
},
17761846
{
@@ -1823,9 +1893,15 @@ describe('Execute: defer directive', () => {
18231893
data: {
18241894
hero: { id: '1' },
18251895
},
1896+
pending: [{ path: ['hero'] }],
18261897
hasNext: true,
18271898
},
18281899
{
1900+
pending: [
1901+
{ path: ['hero', 'friends', 0] },
1902+
{ path: ['hero', 'friends', 1] },
1903+
{ path: ['hero', 'friends', 2] },
1904+
],
18291905
incremental: [
18301906
{
18311907
data: { name: 'slow', friends: [{}, {}, {}] },
@@ -1874,9 +1950,15 @@ describe('Execute: defer directive', () => {
18741950
data: {
18751951
hero: { id: '1' },
18761952
},
1953+
pending: [{ path: ['hero'] }],
18771954
hasNext: true,
18781955
},
18791956
{
1957+
pending: [
1958+
{ path: ['hero', 'friends', 0] },
1959+
{ path: ['hero', 'friends', 1] },
1960+
{ path: ['hero', 'friends', 2] },
1961+
],
18801962
incremental: [
18811963
{
18821964
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)