Skip to content

Commit 165623a

Browse files
committed
add pending notifications
1 parent 9b32799 commit 165623a

File tree

4 files changed

+203
-4
lines changed

4 files changed

+203
-4
lines changed

src/execution/__tests__/defer-test.ts

+78
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
{
@@ -608,6 +628,10 @@ describe('Execute: defer directive', () => {
608628
data: {
609629
hero: {},
610630
},
631+
pending: [
632+
{ path: [], label: 'DeferName' },
633+
{ path: ['hero'], label: 'DeferID' },
634+
],
611635
hasNext: true,
612636
},
613637
{
@@ -651,9 +675,11 @@ describe('Execute: defer directive', () => {
651675
expectJSON(result).toDeepEqual([
652676
{
653677
data: {},
678+
pending: [{ path: [], label: 'DeferName' }],
654679
hasNext: true,
655680
},
656681
{
682+
pending: [{ path: ['hero'], label: 'DeferID' }],
657683
incremental: [
658684
{
659685
data: {
@@ -713,6 +739,20 @@ describe('Execute: defer directive', () => {
713739
expectJSON(result).toDeepEqual([
714740
{
715741
data: { hero: { friends: [{}, {}, {}] } },
742+
pending: [
743+
{ path: ['hero', 'friends', 0] },
744+
{ path: ['hero', 'friends', 0] },
745+
{ path: ['hero', 'friends', 0] },
746+
{ path: ['hero', 'friends', 0] },
747+
{ path: ['hero', 'friends', 1] },
748+
{ path: ['hero', 'friends', 1] },
749+
{ path: ['hero', 'friends', 1] },
750+
{ path: ['hero', 'friends', 1] },
751+
{ path: ['hero', 'friends', 2] },
752+
{ path: ['hero', 'friends', 2] },
753+
{ path: ['hero', 'friends', 2] },
754+
{ path: ['hero', 'friends', 2] },
755+
],
716756
hasNext: true,
717757
},
718758
{
@@ -786,6 +826,7 @@ describe('Execute: defer directive', () => {
786826
},
787827
},
788828
},
829+
pending: [{ path: ['hero'] }],
789830
hasNext: true,
790831
},
791832
{
@@ -825,9 +866,11 @@ describe('Execute: defer directive', () => {
825866
data: {
826867
hero: {},
827868
},
869+
pending: [{ path: ['hero'] }],
828870
hasNext: true,
829871
},
830872
{
873+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
831874
incremental: [
832875
{
833876
data: {
@@ -901,9 +944,11 @@ describe('Execute: defer directive', () => {
901944
},
902945
},
903946
},
947+
pending: [{ path: ['hero'] }],
904948
hasNext: true,
905949
},
906950
{
951+
pending: [{ path: ['hero', 'nestedObject'] }],
907952
incremental: [
908953
{
909954
data: { bar: 'bar' },
@@ -914,6 +959,7 @@ describe('Execute: defer directive', () => {
914959
hasNext: true,
915960
},
916961
{
962+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
917963
incremental: [
918964
{
919965
data: { baz: 'baz' },
@@ -970,9 +1016,14 @@ describe('Execute: defer directive', () => {
9701016
},
9711017
},
9721018
},
1019+
pending: [
1020+
{ path: ['hero'] },
1021+
{ path: ['hero', 'nestedObject', 'deeperObject'] },
1022+
],
9731023
hasNext: true,
9741024
},
9751025
{
1026+
pending: [{ path: ['hero', 'nestedObject', 'deeperObject'] }],
9761027
incremental: [
9771028
{
9781029
data: {
@@ -1043,6 +1094,7 @@ describe('Execute: defer directive', () => {
10431094
},
10441095
},
10451096
},
1097+
pending: [{ path: [] }, { path: ['a', 'b'] }],
10461098
hasNext: true,
10471099
},
10481100
{
@@ -1092,6 +1144,7 @@ describe('Execute: defer directive', () => {
10921144
data: {
10931145
a: {},
10941146
},
1147+
pending: [{ path: [] }, { path: ['a'] }],
10951148
hasNext: true,
10961149
},
10971150
{
@@ -1154,6 +1207,7 @@ describe('Execute: defer directive', () => {
11541207
data: {
11551208
a: {},
11561209
},
1210+
pending: [{ path: [] }, { path: ['a'] }],
11571211
hasNext: true,
11581212
},
11591213
{
@@ -1216,6 +1270,7 @@ describe('Execute: defer directive', () => {
12161270
data: {
12171271
a: {},
12181272
},
1273+
pending: [{ path: [] }, { path: ['a'] }],
12191274
hasNext: true,
12201275
},
12211276
{
@@ -1305,6 +1360,7 @@ describe('Execute: defer directive', () => {
13051360
expectJSON(result).toDeepEqual([
13061361
{
13071362
data: {},
1363+
pending: [{ path: [] }],
13081364
hasNext: true,
13091365
},
13101366
{
@@ -1353,6 +1409,7 @@ describe('Execute: defer directive', () => {
13531409
friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }],
13541410
},
13551411
},
1412+
pending: [{ path: ['hero'] }],
13561413
hasNext: true,
13571414
},
13581415
{
@@ -1388,6 +1445,7 @@ describe('Execute: defer directive', () => {
13881445
expectJSON(result).toDeepEqual([
13891446
{
13901447
data: { hero: { friends: [{ name: 'Han' }] } },
1448+
pending: [{ path: ['hero'] }],
13911449
hasNext: true,
13921450
},
13931451
{
@@ -1424,6 +1482,7 @@ describe('Execute: defer directive', () => {
14241482
expectJSON(result).toDeepEqual([
14251483
{
14261484
data: { hero: { friends: [] } },
1485+
pending: [{ path: ['hero'] }],
14271486
hasNext: true,
14281487
},
14291488
{
@@ -1456,6 +1515,7 @@ describe('Execute: defer directive', () => {
14561515
friends: [{ name: 'Han' }, { name: 'Leia' }, { name: 'C-3PO' }],
14571516
},
14581517
},
1518+
pending: [{ path: ['hero'] }],
14591519
hasNext: true,
14601520
},
14611521
{
@@ -1503,6 +1563,7 @@ describe('Execute: defer directive', () => {
15031563
expectJSON(result).toDeepEqual([
15041564
{
15051565
data: { hero: { friends: [] } },
1566+
pending: [{ path: ['hero'] }],
15061567
hasNext: true,
15071568
},
15081569
{
@@ -1536,6 +1597,7 @@ describe('Execute: defer directive', () => {
15361597
expectJSON(result).toDeepEqual([
15371598
{
15381599
data: { hero: { nestedObject: null } },
1600+
pending: [{ path: ['hero'] }],
15391601
hasNext: true,
15401602
},
15411603
{
@@ -1569,6 +1631,7 @@ describe('Execute: defer directive', () => {
15691631
expectJSON(result).toDeepEqual([
15701632
{
15711633
data: { hero: { nestedObject: { name: 'foo' } } },
1634+
pending: [{ path: ['hero'] }],
15721635
hasNext: true,
15731636
},
15741637
{
@@ -1601,6 +1664,7 @@ describe('Execute: defer directive', () => {
16011664
expectJSON(result).toDeepEqual([
16021665
{
16031666
data: { hero: { id: '1' } },
1667+
pending: [{ path: ['hero'] }],
16041668
hasNext: true,
16051669
},
16061670
{
@@ -1643,6 +1707,7 @@ describe('Execute: defer directive', () => {
16431707
expectJSON(result).toDeepEqual([
16441708
{
16451709
data: { hero: { id: '1' } },
1710+
pending: [{ path: ['hero'] }],
16461711
hasNext: true,
16471712
},
16481713
{
@@ -1721,6 +1786,7 @@ describe('Execute: defer directive', () => {
17211786
expectJSON(result).toDeepEqual([
17221787
{
17231788
data: { hero: { id: '1' } },
1789+
pending: [{ path: ['hero'] }],
17241790
hasNext: true,
17251791
},
17261792
{
@@ -1773,9 +1839,15 @@ describe('Execute: defer directive', () => {
17731839
data: {
17741840
hero: { id: '1' },
17751841
},
1842+
pending: [{ path: ['hero'] }],
17761843
hasNext: true,
17771844
},
17781845
{
1846+
pending: [
1847+
{ path: ['hero', 'friends', 0] },
1848+
{ path: ['hero', 'friends', 1] },
1849+
{ path: ['hero', 'friends', 2] },
1850+
],
17791851
incremental: [
17801852
{
17811853
data: { name: 'slow', friends: [{}, {}, {}] },
@@ -1824,9 +1896,15 @@ describe('Execute: defer directive', () => {
18241896
data: {
18251897
hero: { id: '1' },
18261898
},
1899+
pending: [{ path: ['hero'] }],
18271900
hasNext: true,
18281901
},
18291902
{
1903+
pending: [
1904+
{ path: ['hero', 'friends', 0] },
1905+
{ path: ['hero', 'friends', 1] },
1906+
{ path: ['hero', 'friends', 2] },
1907+
],
18301908
incremental: [
18311909
{
18321910
data: {

src/execution/__tests__/mutations-test.ts

+2
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)