houdini 0.17.13 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/build/cmd-cjs/index.js +438 -201
  2. package/build/cmd-esm/index.js +438 -201
  3. package/build/codegen/utils/flattenSelections.d.ts +3 -1
  4. package/build/codegen-cjs/index.js +405 -180
  5. package/build/codegen-esm/index.js +405 -180
  6. package/build/lib/config.d.ts +8 -3
  7. package/build/lib-cjs/index.js +141 -81
  8. package/build/lib-esm/index.js +141 -81
  9. package/build/runtime/cache/subscription.d.ts +3 -3
  10. package/build/runtime/lib/config.d.ts +2 -1
  11. package/build/runtime/lib/scalars.d.ts +2 -2
  12. package/build/runtime/lib/selection.d.ts +2 -0
  13. package/build/runtime/lib/types.d.ts +26 -16
  14. package/build/runtime-cjs/cache/cache.js +38 -23
  15. package/build/runtime-cjs/cache/lists.js +40 -26
  16. package/build/runtime-cjs/cache/subscription.d.ts +3 -3
  17. package/build/runtime-cjs/cache/subscription.js +23 -21
  18. package/build/runtime-cjs/lib/config.d.ts +2 -1
  19. package/build/runtime-cjs/lib/scalars.d.ts +2 -2
  20. package/build/runtime-cjs/lib/scalars.js +9 -6
  21. package/build/runtime-cjs/lib/selection.d.ts +2 -0
  22. package/build/runtime-cjs/lib/selection.js +39 -0
  23. package/build/runtime-cjs/lib/types.d.ts +26 -16
  24. package/build/runtime-esm/cache/cache.js +38 -23
  25. package/build/runtime-esm/cache/lists.js +40 -26
  26. package/build/runtime-esm/cache/subscription.d.ts +3 -3
  27. package/build/runtime-esm/cache/subscription.js +23 -21
  28. package/build/runtime-esm/lib/config.d.ts +2 -1
  29. package/build/runtime-esm/lib/scalars.d.ts +2 -2
  30. package/build/runtime-esm/lib/scalars.js +9 -6
  31. package/build/runtime-esm/lib/selection.d.ts +2 -0
  32. package/build/runtime-esm/lib/selection.js +15 -0
  33. package/build/runtime-esm/lib/types.d.ts +26 -16
  34. package/build/test/index.d.ts +1 -2
  35. package/build/test-cjs/index.js +485 -195
  36. package/build/test-esm/index.js +485 -195
  37. package/build/vite-cjs/index.js +438 -193
  38. package/build/vite-esm/index.js +438 -193
  39. package/package.json +2 -2
  40. package/build/runtime-cjs/cache/tests/availability.test.js +0 -357
  41. package/build/runtime-cjs/cache/tests/gc.test.js +0 -271
  42. package/build/runtime-cjs/cache/tests/keys.test.js +0 -34
  43. package/build/runtime-cjs/cache/tests/list.test.js +0 -3390
  44. package/build/runtime-cjs/cache/tests/readwrite.test.js +0 -1076
  45. package/build/runtime-cjs/cache/tests/scalars.test.js +0 -181
  46. package/build/runtime-cjs/cache/tests/storage.test.js +0 -280
  47. package/build/runtime-cjs/cache/tests/subscriptions.test.js +0 -1469
  48. package/build/runtime-cjs/lib/scalars.test.js +0 -736
  49. package/build/runtime-esm/cache/tests/availability.test.js +0 -356
  50. package/build/runtime-esm/cache/tests/gc.test.js +0 -270
  51. package/build/runtime-esm/cache/tests/keys.test.js +0 -33
  52. package/build/runtime-esm/cache/tests/list.test.js +0 -3389
  53. package/build/runtime-esm/cache/tests/readwrite.test.js +0 -1075
  54. package/build/runtime-esm/cache/tests/scalars.test.js +0 -180
  55. package/build/runtime-esm/cache/tests/storage.test.js +0 -279
  56. package/build/runtime-esm/cache/tests/subscriptions.test.js +0 -1468
  57. package/build/runtime-esm/lib/scalars.test.js +0 -735
@@ -1,1076 +0,0 @@
1
- "use strict";
2
- var import_vitest = require("vitest");
3
- var import_test = require("../../../test");
4
- var import_cache = require("../cache");
5
- const config = (0, import_test.testConfigFile)();
6
- (0, import_vitest.test)("write selection to root", function() {
7
- const cache = new import_cache.Cache(config);
8
- const data = {
9
- viewer: {
10
- id: "1",
11
- firstName: "bob"
12
- }
13
- };
14
- const selection = {
15
- viewer: {
16
- type: "User",
17
- keyRaw: "viewer",
18
- fields: {
19
- id: {
20
- type: "ID",
21
- keyRaw: "id"
22
- },
23
- firstName: {
24
- type: "String",
25
- keyRaw: "firstName"
26
- }
27
- }
28
- }
29
- };
30
- cache.write({
31
- selection,
32
- data
33
- });
34
- (0, import_vitest.expect)(
35
- cache.read({
36
- selection
37
- }).data
38
- ).toEqual({
39
- viewer: {
40
- id: "1",
41
- firstName: "bob"
42
- }
43
- });
44
- });
45
- (0, import_vitest.test)("linked records with updates", function() {
46
- const cache = new import_cache.Cache(config);
47
- const deeplyNestedSelection = {
48
- viewer: {
49
- type: "User",
50
- keyRaw: "viewer",
51
- fields: {
52
- id: {
53
- type: "ID",
54
- keyRaw: "id"
55
- },
56
- firstName: {
57
- type: "String",
58
- keyRaw: "firstName"
59
- },
60
- parent: {
61
- type: "User",
62
- keyRaw: "parent",
63
- fields: {
64
- id: {
65
- type: "ID",
66
- keyRaw: "id"
67
- },
68
- firstName: {
69
- type: "String",
70
- keyRaw: "firstName"
71
- }
72
- }
73
- }
74
- }
75
- }
76
- };
77
- const userFields = {
78
- id: {
79
- type: "ID",
80
- keyRaw: "id"
81
- },
82
- firstName: {
83
- type: "String",
84
- keyRaw: "firstName"
85
- },
86
- parent: {
87
- type: "User",
88
- keyRaw: "parent",
89
- nullable: true,
90
- fields: {
91
- id: {
92
- type: "ID",
93
- keyRaw: "id"
94
- }
95
- }
96
- }
97
- };
98
- cache.write({
99
- selection: deeplyNestedSelection,
100
- data: {
101
- viewer: {
102
- id: "1",
103
- firstName: "bob",
104
- parent: {
105
- id: "2",
106
- firstName: "jane"
107
- }
108
- }
109
- }
110
- });
111
- (0, import_vitest.expect)(cache.read({ selection: userFields, parent: "User:1" }).data).toEqual({
112
- id: "1",
113
- firstName: "bob",
114
- parent: {
115
- id: "2"
116
- }
117
- });
118
- (0, import_vitest.expect)(cache.read({ selection: userFields, parent: "User:2" }).data).toEqual({
119
- id: "2",
120
- firstName: "jane",
121
- parent: null
122
- });
123
- cache.write({
124
- selection: deeplyNestedSelection,
125
- data: {
126
- viewer: {
127
- id: "2",
128
- firstName: "jane-prime",
129
- parent: {
130
- id: "3",
131
- firstName: "mary"
132
- }
133
- }
134
- }
135
- });
136
- (0, import_vitest.expect)(cache.read({ selection: userFields, parent: "User:2" }).data).toEqual({
137
- id: "2",
138
- firstName: "jane-prime",
139
- parent: {
140
- id: "3"
141
- }
142
- });
143
- (0, import_vitest.expect)(cache.read({ selection: userFields, parent: "User:3" }).data).toEqual({
144
- id: "3",
145
- firstName: "mary",
146
- parent: null
147
- });
148
- });
149
- (0, import_vitest.test)("linked lists", function() {
150
- const cache = new import_cache.Cache(config);
151
- const selection = {
152
- viewer: {
153
- type: "User",
154
- keyRaw: "viewer",
155
- fields: {
156
- id: {
157
- type: "ID",
158
- keyRaw: "id"
159
- },
160
- firstName: {
161
- type: "String",
162
- keyRaw: "firstName"
163
- },
164
- friends: {
165
- type: "User",
166
- keyRaw: "friends",
167
- fields: {
168
- id: {
169
- type: "ID",
170
- keyRaw: "id"
171
- },
172
- firstName: {
173
- type: "String",
174
- keyRaw: "firstName"
175
- }
176
- }
177
- }
178
- }
179
- }
180
- };
181
- cache.write({
182
- selection,
183
- data: {
184
- viewer: {
185
- id: "1",
186
- firstName: "bob",
187
- friends: [
188
- {
189
- id: "2",
190
- firstName: "jane"
191
- },
192
- {
193
- id: "3",
194
- firstName: "mary"
195
- }
196
- ]
197
- }
198
- }
199
- });
200
- (0, import_vitest.expect)(cache.read({ selection: selection.viewer.fields, parent: "User:1" }).data).toEqual({
201
- id: "1",
202
- firstName: "bob",
203
- friends: [
204
- {
205
- id: "2",
206
- firstName: "jane"
207
- },
208
- {
209
- id: "3",
210
- firstName: "mary"
211
- }
212
- ]
213
- });
214
- });
215
- (0, import_vitest.test)("list as value with args", function() {
216
- const cache = new import_cache.Cache(config);
217
- cache.write({
218
- selection: {
219
- viewer: {
220
- type: "User",
221
- keyRaw: "viewer",
222
- fields: {
223
- id: {
224
- type: "ID",
225
- keyRaw: "id"
226
- },
227
- firstName: {
228
- type: "String",
229
- keyRaw: "firstName"
230
- },
231
- favoriteColors: {
232
- type: "String",
233
- keyRaw: 'favoriteColors(where: "foo")'
234
- }
235
- }
236
- }
237
- },
238
- data: {
239
- viewer: {
240
- id: "1",
241
- firstName: "bob",
242
- favoriteColors: ["red", "green", "blue"]
243
- }
244
- }
245
- });
246
- (0, import_vitest.expect)(
247
- cache.read({
248
- selection: {
249
- favoriteColors: {
250
- type: "String",
251
- keyRaw: 'favoriteColors(where: "foo")'
252
- }
253
- },
254
- parent: "User:1"
255
- }).data
256
- ).toEqual({
257
- favoriteColors: ["red", "green", "blue"]
258
- });
259
- });
260
- (0, import_vitest.test)("writing abstract objects", function() {
261
- const cache = new import_cache.Cache(config);
262
- const data = {
263
- viewer: {
264
- __typename: "User",
265
- id: "1",
266
- firstName: "bob"
267
- }
268
- };
269
- cache.write({
270
- selection: {
271
- viewer: {
272
- type: "Node",
273
- abstract: true,
274
- keyRaw: "viewer",
275
- fields: {
276
- __typename: {
277
- type: "String",
278
- keyRaw: "__typename"
279
- },
280
- id: {
281
- type: "ID",
282
- keyRaw: "id"
283
- },
284
- firstName: {
285
- type: "String",
286
- keyRaw: "firstName"
287
- }
288
- }
289
- }
290
- },
291
- data
292
- });
293
- (0, import_vitest.expect)(
294
- cache.read({
295
- parent: "User:1",
296
- selection: {
297
- __typename: {
298
- type: "String",
299
- keyRaw: "__typename"
300
- },
301
- id: {
302
- type: "ID",
303
- keyRaw: "id"
304
- },
305
- firstName: {
306
- type: "String",
307
- keyRaw: "firstName"
308
- }
309
- }
310
- }).data
311
- ).toEqual({
312
- __typename: "User",
313
- id: "1",
314
- firstName: "bob"
315
- });
316
- });
317
- (0, import_vitest.test)("writing abstract lists", function() {
318
- const cache = new import_cache.Cache(config);
319
- const data = {
320
- nodes: [
321
- {
322
- __typename: "User",
323
- id: "1",
324
- firstName: "bob"
325
- },
326
- {
327
- __typename: "User",
328
- id: "2",
329
- firstName: "bob"
330
- }
331
- ]
332
- };
333
- cache.write({
334
- selection: {
335
- nodes: {
336
- type: "Node",
337
- abstract: true,
338
- keyRaw: "nodes",
339
- fields: {
340
- __typename: {
341
- type: "String",
342
- keyRaw: "__typename"
343
- },
344
- id: {
345
- type: "ID",
346
- keyRaw: "id"
347
- },
348
- firstName: {
349
- type: "String",
350
- keyRaw: "firstName"
351
- }
352
- }
353
- }
354
- },
355
- data
356
- });
357
- (0, import_vitest.expect)(
358
- cache.read({
359
- parent: "User:1",
360
- selection: {
361
- __typename: {
362
- type: "String",
363
- keyRaw: "__typename"
364
- },
365
- id: {
366
- type: "ID",
367
- keyRaw: "id"
368
- },
369
- firstName: {
370
- type: "String",
371
- keyRaw: "firstName"
372
- }
373
- }
374
- }).data
375
- ).toEqual({
376
- __typename: "User",
377
- id: "1",
378
- firstName: "bob"
379
- });
380
- });
381
- (0, import_vitest.test)("can pull enum from cached values", function() {
382
- const cache = new import_cache.Cache(config);
383
- const selection = {
384
- node: {
385
- type: "Node",
386
- keyRaw: "node",
387
- fields: {
388
- enumValue: {
389
- type: "MyEnum",
390
- keyRaw: "enumValue"
391
- },
392
- id: {
393
- type: "ID",
394
- keyRaw: "id"
395
- }
396
- }
397
- }
398
- };
399
- const data = {
400
- node: {
401
- id: "1",
402
- enumValue: "Hello"
403
- }
404
- };
405
- cache.write({ selection, data });
406
- (0, import_vitest.expect)(cache.read({ selection }).data).toEqual({
407
- node: {
408
- id: "1",
409
- enumValue: "Hello"
410
- }
411
- });
412
- });
413
- (0, import_vitest.test)("can store and retrieve lists with null values", function() {
414
- const cache = new import_cache.Cache(config);
415
- const selection = {
416
- viewer: {
417
- type: "User",
418
- keyRaw: "viewer",
419
- fields: {
420
- id: {
421
- type: "ID",
422
- keyRaw: "id"
423
- },
424
- firstName: {
425
- type: "String",
426
- keyRaw: "firstName"
427
- },
428
- friends: {
429
- type: "User",
430
- keyRaw: "friends",
431
- fields: {
432
- id: {
433
- type: "ID",
434
- keyRaw: "id"
435
- },
436
- firstName: {
437
- type: "String",
438
- keyRaw: "firstName"
439
- }
440
- }
441
- }
442
- }
443
- }
444
- };
445
- cache.write({
446
- selection,
447
- data: {
448
- viewer: {
449
- id: "1",
450
- firstName: "bob",
451
- friends: [
452
- {
453
- id: "2",
454
- firstName: "jane"
455
- },
456
- null
457
- ]
458
- }
459
- }
460
- });
461
- (0, import_vitest.expect)(cache.read({ selection }).data).toEqual({
462
- viewer: {
463
- id: "1",
464
- firstName: "bob",
465
- friends: [
466
- {
467
- id: "2",
468
- firstName: "jane"
469
- },
470
- null
471
- ]
472
- }
473
- });
474
- });
475
- (0, import_vitest.test)("can store and retrieve lists of lists of records", function() {
476
- const cache = new import_cache.Cache(config);
477
- const selection = {
478
- viewer: {
479
- type: "User",
480
- keyRaw: "viewer",
481
- fields: {
482
- id: {
483
- type: "ID",
484
- keyRaw: "id"
485
- },
486
- firstName: {
487
- type: "String",
488
- keyRaw: "firstName"
489
- },
490
- friends: {
491
- type: "User",
492
- keyRaw: "friends",
493
- fields: {
494
- id: {
495
- type: "ID",
496
- keyRaw: "id"
497
- },
498
- firstName: {
499
- type: "String",
500
- keyRaw: "firstName"
501
- }
502
- }
503
- }
504
- }
505
- }
506
- };
507
- cache.write({
508
- selection,
509
- data: {
510
- viewer: {
511
- id: "1",
512
- firstName: "bob",
513
- friends: [
514
- [
515
- {
516
- id: "2",
517
- firstName: "jane"
518
- },
519
- null
520
- ],
521
- [
522
- {
523
- id: "3",
524
- firstName: "jane"
525
- },
526
- {
527
- id: "4",
528
- firstName: "jane"
529
- }
530
- ]
531
- ]
532
- }
533
- }
534
- });
535
- (0, import_vitest.expect)(cache.read({ selection }).data).toEqual({
536
- viewer: {
537
- id: "1",
538
- firstName: "bob",
539
- friends: [
540
- [
541
- {
542
- id: "2",
543
- firstName: "jane"
544
- },
545
- null
546
- ],
547
- [
548
- {
549
- id: "3",
550
- firstName: "jane"
551
- },
552
- {
553
- id: "4",
554
- firstName: "jane"
555
- }
556
- ]
557
- ]
558
- }
559
- });
560
- });
561
- (0, import_vitest.test)("can store and retrieve links with null values", function() {
562
- const cache = new import_cache.Cache(config);
563
- const selection = {
564
- viewer: {
565
- type: "User",
566
- keyRaw: "viewer",
567
- nullable: true,
568
- fields: {
569
- id: {
570
- type: "ID",
571
- keyRaw: "id"
572
- },
573
- firstName: {
574
- type: "String",
575
- keyRaw: "firstName"
576
- },
577
- friends: {
578
- type: "User",
579
- keyRaw: "friends",
580
- fields: {
581
- id: {
582
- type: "ID",
583
- keyRaw: "id"
584
- },
585
- firstName: {
586
- type: "String",
587
- keyRaw: "firstName"
588
- }
589
- }
590
- }
591
- }
592
- }
593
- };
594
- cache.write({
595
- selection,
596
- data: {
597
- viewer: null
598
- }
599
- });
600
- (0, import_vitest.expect)(cache.read({ selection }).data).toEqual({
601
- viewer: null
602
- });
603
- });
604
- (0, import_vitest.test)("can write list of just null", function() {
605
- const cache = new import_cache.Cache(config);
606
- const selection = {
607
- viewer: {
608
- type: "User",
609
- keyRaw: "viewer",
610
- fields: {
611
- id: {
612
- type: "ID",
613
- keyRaw: "id"
614
- },
615
- firstName: {
616
- type: "String",
617
- keyRaw: "firstName"
618
- },
619
- friends: {
620
- type: "User",
621
- keyRaw: "friends",
622
- fields: {
623
- id: {
624
- type: "ID",
625
- keyRaw: "id"
626
- },
627
- firstName: {
628
- type: "String",
629
- keyRaw: "firstName"
630
- }
631
- }
632
- }
633
- }
634
- }
635
- };
636
- cache.write({
637
- selection,
638
- data: {
639
- viewer: {
640
- id: "1",
641
- firstName: "bob",
642
- friends: [null]
643
- }
644
- }
645
- });
646
- (0, import_vitest.expect)(cache.read({ selection }).data).toEqual({
647
- viewer: {
648
- id: "1",
649
- firstName: "bob",
650
- friends: [null]
651
- }
652
- });
653
- });
654
- (0, import_vitest.test)("null-value cascade from field value", function() {
655
- const cache = new import_cache.Cache(config);
656
- cache.write({
657
- selection: {
658
- viewer: {
659
- type: "User",
660
- keyRaw: "viewer",
661
- fields: {
662
- id: {
663
- keyRaw: "id",
664
- type: "String"
665
- }
666
- }
667
- }
668
- },
669
- data: {
670
- viewer: {
671
- id: "1"
672
- }
673
- }
674
- });
675
- (0, import_vitest.expect)(
676
- cache.read({
677
- selection: {
678
- viewer: {
679
- type: "User",
680
- keyRaw: "viewer",
681
- nullable: true,
682
- fields: {
683
- id: {
684
- keyRaw: "id",
685
- type: "String"
686
- }
687
- }
688
- }
689
- }
690
- }).data
691
- ).toEqual({
692
- viewer: {
693
- id: "1"
694
- }
695
- });
696
- (0, import_vitest.expect)(
697
- cache.read({
698
- selection: {
699
- viewer: {
700
- type: "User",
701
- keyRaw: "viewer",
702
- nullable: true,
703
- fields: {
704
- firstName: {
705
- keyRaw: "firstName",
706
- type: "String"
707
- },
708
- id: {
709
- keyRaw: "id",
710
- type: "String"
711
- }
712
- }
713
- }
714
- }
715
- }).data
716
- ).toEqual({
717
- viewer: null
718
- });
719
- });
720
- (0, import_vitest.test)("null-value field", function() {
721
- const cache = new import_cache.Cache(config);
722
- cache.write({
723
- selection: {
724
- viewer: {
725
- type: "User",
726
- keyRaw: "viewer",
727
- fields: {
728
- id: {
729
- keyRaw: "id",
730
- type: "String"
731
- },
732
- firstName: {
733
- keyRaw: "firstName",
734
- type: "String"
735
- }
736
- }
737
- }
738
- },
739
- data: {
740
- viewer: {
741
- id: "1",
742
- firstName: null
743
- }
744
- }
745
- });
746
- (0, import_vitest.expect)(
747
- cache.read({
748
- selection: {
749
- viewer: {
750
- type: "User",
751
- keyRaw: "viewer",
752
- nullable: true,
753
- fields: {
754
- id: {
755
- keyRaw: "id",
756
- type: "String"
757
- }
758
- }
759
- }
760
- }
761
- }).data
762
- ).toEqual({
763
- viewer: {
764
- id: "1"
765
- }
766
- });
767
- (0, import_vitest.expect)(
768
- cache.read({
769
- selection: {
770
- viewer: {
771
- type: "User",
772
- keyRaw: "viewer",
773
- nullable: true,
774
- fields: {
775
- firstName: {
776
- keyRaw: "firstName",
777
- type: "String",
778
- nullable: true
779
- }
780
- }
781
- }
782
- }
783
- }).data
784
- ).toEqual({
785
- viewer: {
786
- firstName: null
787
- }
788
- });
789
- });
790
- (0, import_vitest.test)("null-value cascade from object value", function() {
791
- const cache = new import_cache.Cache(config);
792
- cache.write({
793
- selection: {
794
- viewer: {
795
- type: "User",
796
- keyRaw: "viewer",
797
- fields: {
798
- id: {
799
- keyRaw: "id",
800
- type: "String"
801
- }
802
- }
803
- }
804
- },
805
- data: {
806
- viewer: {
807
- id: "1"
808
- }
809
- }
810
- });
811
- (0, import_vitest.expect)(
812
- cache.read({
813
- selection: {
814
- viewer: {
815
- type: "User",
816
- keyRaw: "viewer",
817
- nullable: true,
818
- fields: {
819
- id: {
820
- keyRaw: "id",
821
- type: "String"
822
- },
823
- parent: {
824
- keyRaw: "parent",
825
- type: "User"
826
- }
827
- }
828
- }
829
- }
830
- })
831
- ).toEqual({
832
- partial: true,
833
- data: {
834
- viewer: null
835
- }
836
- });
837
- (0, import_vitest.expect)(
838
- cache.read({
839
- selection: {
840
- viewer: {
841
- type: "User",
842
- keyRaw: "viewer",
843
- nullable: true,
844
- fields: {
845
- id: {
846
- keyRaw: "id",
847
- type: "String"
848
- },
849
- parent: {
850
- keyRaw: "parent",
851
- type: "User",
852
- nullable: true
853
- }
854
- }
855
- }
856
- }
857
- })
858
- ).toEqual({
859
- partial: true,
860
- data: {
861
- viewer: {
862
- id: "1",
863
- parent: null
864
- }
865
- }
866
- });
867
- });
868
- (0, import_vitest.test)("null-value cascade to root", function() {
869
- const cache = new import_cache.Cache(config);
870
- cache.write({
871
- selection: {
872
- viewer: {
873
- type: "User",
874
- keyRaw: "viewer",
875
- fields: {
876
- id: {
877
- keyRaw: "id",
878
- type: "String"
879
- }
880
- }
881
- }
882
- },
883
- data: {
884
- viewer: {
885
- id: "1"
886
- }
887
- }
888
- });
889
- (0, import_vitest.expect)(
890
- cache.read({
891
- selection: {
892
- viewer: {
893
- type: "User",
894
- keyRaw: "viewer",
895
- fields: {
896
- id: {
897
- keyRaw: "id",
898
- type: "String"
899
- },
900
- parent: {
901
- keyRaw: "parent",
902
- type: "User"
903
- }
904
- }
905
- }
906
- }
907
- })
908
- ).toEqual({
909
- data: null,
910
- partial: true
911
- });
912
- (0, import_vitest.expect)(
913
- cache.read({
914
- selection: {
915
- viewer: {
916
- type: "User",
917
- keyRaw: "viewer",
918
- nullable: true,
919
- fields: {
920
- parent: {
921
- keyRaw: "parent",
922
- type: "User"
923
- },
924
- id: {
925
- keyRaw: "id",
926
- type: "String"
927
- }
928
- }
929
- }
930
- }
931
- }).data
932
- ).toEqual({
933
- viewer: null
934
- });
935
- });
936
- (0, import_vitest.test)("must have a single value in order to use partial data", function() {
937
- const cache = new import_cache.Cache(config);
938
- cache.write({
939
- selection: {
940
- viewer: {
941
- type: "User",
942
- keyRaw: "viewer",
943
- nullable: true,
944
- fields: {
945
- id: {
946
- keyRaw: "id",
947
- type: "String"
948
- }
949
- }
950
- }
951
- },
952
- data: {
953
- viewer: {
954
- id: "1"
955
- }
956
- }
957
- });
958
- (0, import_vitest.expect)(
959
- cache.read({
960
- selection: {
961
- viewer: {
962
- type: "User",
963
- keyRaw: "viewer",
964
- nullable: true,
965
- fields: {
966
- parent: {
967
- keyRaw: "parent",
968
- type: "User"
969
- }
970
- }
971
- }
972
- }
973
- })
974
- ).toEqual({
975
- partial: false,
976
- data: null
977
- });
978
- (0, import_vitest.expect)(
979
- cache.read({
980
- selection: {
981
- viewer: {
982
- type: "User",
983
- keyRaw: "viewer",
984
- nullable: true,
985
- fields: {
986
- id: {
987
- keyRaw: "id",
988
- type: "String"
989
- },
990
- parent: {
991
- keyRaw: "parent",
992
- type: "User"
993
- }
994
- }
995
- }
996
- }
997
- })
998
- ).toEqual({
999
- partial: true,
1000
- data: {
1001
- viewer: null
1002
- }
1003
- });
1004
- });
1005
- (0, import_vitest.test)("reading an empty list counts as data", function() {
1006
- const cache = new import_cache.Cache(config);
1007
- cache.write({
1008
- selection: {
1009
- viewer: {
1010
- type: "User",
1011
- keyRaw: "viewer",
1012
- nullable: true,
1013
- fields: {
1014
- id: {
1015
- keyRaw: "id",
1016
- type: "String"
1017
- },
1018
- friends: {
1019
- type: "User",
1020
- keyRaw: "friends",
1021
- fields: {
1022
- id: {
1023
- type: "ID",
1024
- keyRaw: "id"
1025
- },
1026
- firstName: {
1027
- type: "String",
1028
- keyRaw: "firstName"
1029
- }
1030
- }
1031
- }
1032
- }
1033
- }
1034
- },
1035
- data: {
1036
- viewer: {
1037
- id: "1",
1038
- friends: []
1039
- }
1040
- }
1041
- });
1042
- (0, import_vitest.expect)(
1043
- cache.read({
1044
- selection: {
1045
- viewer: {
1046
- type: "User",
1047
- keyRaw: "viewer",
1048
- nullable: true,
1049
- fields: {
1050
- friends: {
1051
- type: "User",
1052
- keyRaw: "friends",
1053
- fields: {
1054
- id: {
1055
- type: "ID",
1056
- keyRaw: "id"
1057
- },
1058
- firstName: {
1059
- type: "String",
1060
- keyRaw: "firstName"
1061
- }
1062
- }
1063
- }
1064
- }
1065
- }
1066
- }
1067
- })
1068
- ).toEqual({
1069
- partial: false,
1070
- data: {
1071
- viewer: {
1072
- friends: []
1073
- }
1074
- }
1075
- });
1076
- });