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,736 +0,0 @@
1
- "use strict";
2
- var import_vitest = require("vitest");
3
- var import_test = require("../../test");
4
- var import_config = require("./config");
5
- var import_scalars = require("./scalars");
6
- var import_types = require("./types");
7
- (0, import_vitest.beforeEach)(
8
- () => (0, import_config.setMockConfig)({
9
- client: "",
10
- scalars: {
11
- DateTime: {
12
- type: "Date",
13
- unmarshal(val) {
14
- return new Date(val);
15
- },
16
- marshal(date) {
17
- return date.getTime();
18
- }
19
- }
20
- }
21
- })
22
- );
23
- const artifact = {
24
- name: "AllItems",
25
- kind: import_types.ArtifactKind.Query,
26
- hash: "hash",
27
- raw: "does not matter",
28
- selection: {
29
- items: {
30
- type: "TodoItem",
31
- keyRaw: "allItems",
32
- fields: {
33
- createdAt: {
34
- type: "DateTime",
35
- keyRaw: "createdAt"
36
- },
37
- dates: {
38
- type: "DateTime",
39
- keyRaw: "dates"
40
- },
41
- creator: {
42
- type: "User",
43
- keyRaw: "creator",
44
- fields: {
45
- firstName: {
46
- type: "String",
47
- keyRaw: "firstName"
48
- }
49
- },
50
- list: {
51
- name: "All_Items",
52
- type: "User",
53
- connection: false
54
- }
55
- }
56
- },
57
- list: {
58
- name: "All_Items",
59
- type: "User",
60
- connection: false
61
- }
62
- }
63
- },
64
- rootType: "Query",
65
- input: {
66
- fields: {
67
- date: "NestedDate",
68
- booleanValue: "Boolean",
69
- enumValue: "EnumValue"
70
- },
71
- types: {
72
- NestedDate: {
73
- date: "DateTime",
74
- dates: "DateTime",
75
- nested: "NestedDate",
76
- enumValue: "EnumValue"
77
- }
78
- }
79
- }
80
- };
81
- (0, import_vitest.describe)("marshal inputs", function() {
82
- (0, import_vitest.test)("lists of objects", async function() {
83
- const date1 = new Date(0);
84
- const date2 = new Date(1);
85
- const date3 = new Date(2);
86
- const inputs = await (0, import_scalars.marshalInputs)({
87
- artifact,
88
- input: {
89
- date: [
90
- {
91
- date: date1,
92
- nested: {
93
- date: date2,
94
- nested: {
95
- date: date3,
96
- enumValue: "asdf"
97
- }
98
- }
99
- }
100
- ]
101
- }
102
- });
103
- (0, import_vitest.expect)(inputs).toEqual({
104
- date: [
105
- {
106
- date: date1.getTime(),
107
- nested: {
108
- date: date2.getTime(),
109
- nested: {
110
- date: date3.getTime(),
111
- enumValue: "asdf"
112
- }
113
- }
114
- }
115
- ]
116
- });
117
- });
118
- (0, import_vitest.test)("list of scalars", async function() {
119
- const date1 = new Date(0);
120
- const date2 = new Date(1);
121
- const inputs = await (0, import_scalars.marshalInputs)({
122
- artifact,
123
- input: {
124
- date: [
125
- {
126
- dates: [date1, date2]
127
- }
128
- ]
129
- }
130
- });
131
- (0, import_vitest.expect)(inputs).toEqual({
132
- date: [
133
- {
134
- dates: [date1.getTime(), date2.getTime()]
135
- }
136
- ]
137
- });
138
- });
139
- (0, import_vitest.test)("empty list of scalars", async function() {
140
- const inputs = await (0, import_scalars.marshalInputs)({
141
- artifact,
142
- input: {
143
- date: [
144
- {
145
- dates: []
146
- }
147
- ]
148
- }
149
- });
150
- (0, import_vitest.expect)(inputs).toEqual({
151
- date: [
152
- {
153
- dates: []
154
- }
155
- ]
156
- });
157
- });
158
- (0, import_vitest.test)("root fields", async function() {
159
- const inputs = await (0, import_scalars.marshalInputs)({
160
- artifact,
161
- input: {
162
- booleanValue: true
163
- }
164
- });
165
- (0, import_vitest.expect)(inputs).toEqual({
166
- booleanValue: true
167
- });
168
- });
169
- (0, import_vitest.test)("non-custom scalar fields of objects", async function() {
170
- const inputs = await (0, import_scalars.marshalInputs)({
171
- artifact,
172
- input: {
173
- date: {
174
- name: "hello"
175
- }
176
- }
177
- });
178
- (0, import_vitest.expect)(inputs).toEqual({
179
- date: {
180
- name: "hello"
181
- }
182
- });
183
- });
184
- (0, import_vitest.test)("non-custom scalar fields of lists", async function() {
185
- const inputs = await (0, import_scalars.marshalInputs)({
186
- artifact,
187
- input: {
188
- date: [
189
- {
190
- name: "hello"
191
- }
192
- ]
193
- }
194
- });
195
- (0, import_vitest.expect)(inputs).toEqual({
196
- date: [
197
- {
198
- name: "hello"
199
- }
200
- ]
201
- });
202
- });
203
- (0, import_vitest.test)("null", async function() {
204
- const inputs = await (0, import_scalars.marshalInputs)({
205
- artifact,
206
- input: {
207
- date: null
208
- }
209
- });
210
- (0, import_vitest.expect)(inputs).toEqual({
211
- date: null
212
- });
213
- });
214
- (0, import_vitest.test)("undefined", async function() {
215
- const inputs = await (0, import_scalars.marshalInputs)({
216
- artifact,
217
- input: {
218
- date: void 0
219
- }
220
- });
221
- (0, import_vitest.expect)(inputs).toEqual({
222
- date: void 0
223
- });
224
- });
225
- (0, import_vitest.test)("enums", async function() {
226
- const inputs = await (0, import_scalars.marshalInputs)({
227
- artifact,
228
- input: {
229
- enumValue: "ValueA"
230
- }
231
- });
232
- (0, import_vitest.expect)(inputs).toEqual({
233
- enumValue: "ValueA"
234
- });
235
- });
236
- (0, import_vitest.test)("list of enums", async function() {
237
- const inputs = await (0, import_scalars.marshalInputs)({
238
- artifact,
239
- input: {
240
- enumValue: ["ValueA", "ValueB"]
241
- }
242
- });
243
- (0, import_vitest.expect)(inputs).toEqual({
244
- enumValue: ["ValueA", "ValueB"]
245
- });
246
- });
247
- });
248
- (0, import_vitest.describe)("unmarshal selection", function() {
249
- (0, import_vitest.test)("list of objects", function() {
250
- const date = new Date();
251
- const data = {
252
- items: [
253
- {
254
- createdAt: date.getTime(),
255
- creator: {
256
- firstName: "John"
257
- }
258
- }
259
- ]
260
- };
261
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), artifact.selection, data)).toEqual({
262
- items: [
263
- {
264
- createdAt: date,
265
- creator: {
266
- firstName: "John"
267
- }
268
- }
269
- ]
270
- });
271
- });
272
- (0, import_vitest.test)("list of scalars", function() {
273
- const date1 = new Date(1);
274
- const date2 = new Date(2);
275
- const data = {
276
- items: [
277
- {
278
- dates: [date1.getTime(), date2.getTime()]
279
- }
280
- ]
281
- };
282
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), artifact.selection, data)).toEqual({
283
- items: [
284
- {
285
- dates: [date1, date2]
286
- }
287
- ]
288
- });
289
- });
290
- (0, import_vitest.test)("empty list of scalars", function() {
291
- const data = {
292
- items: [
293
- {
294
- dates: []
295
- }
296
- ]
297
- };
298
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), artifact.selection, data)).toEqual({
299
- items: [
300
- {
301
- dates: []
302
- }
303
- ]
304
- });
305
- });
306
- (0, import_vitest.test)("missing unmarshal function", function() {
307
- const config = (0, import_test.testConfigFile)({
308
- scalars: {
309
- DateTime: {
310
- type: "Date",
311
- marshal(date) {
312
- return date.getTime();
313
- }
314
- }
315
- }
316
- });
317
- const data = {
318
- items: [
319
- {
320
- dates: [new Date()]
321
- }
322
- ]
323
- };
324
- (0, import_vitest.expect)(() => (0, import_scalars.unmarshalSelection)(config, artifact.selection, data)).toThrow(
325
- /scalar type DateTime is missing an `unmarshal` function/
326
- );
327
- });
328
- (0, import_vitest.test)("undefined", function() {
329
- const data = {
330
- item: void 0
331
- };
332
- const selection = {
333
- item: {
334
- type: "TodoItem",
335
- keyRaw: "item",
336
- fields: {
337
- createdAt: {
338
- type: "DateTime",
339
- keyRaw: "createdAt"
340
- }
341
- }
342
- }
343
- };
344
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
345
- item: void 0
346
- });
347
- });
348
- (0, import_vitest.test)("null", function() {
349
- const data = {
350
- item: null
351
- };
352
- const selection = {
353
- item: {
354
- type: "TodoItem",
355
- keyRaw: "item",
356
- fields: {
357
- createdAt: {
358
- type: "DateTime",
359
- keyRaw: "createdAt"
360
- }
361
- }
362
- }
363
- };
364
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
365
- item: null
366
- });
367
- });
368
- (0, import_vitest.test)("null inside", function() {
369
- const data = {
370
- item: {
371
- createdAt: null
372
- }
373
- };
374
- const selection = {
375
- item: {
376
- type: "TodoItem",
377
- keyRaw: "item",
378
- fields: {
379
- createdAt: {
380
- type: "DateTime",
381
- keyRaw: "createdAt"
382
- }
383
- }
384
- }
385
- };
386
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
387
- item: {
388
- createdAt: null
389
- }
390
- });
391
- });
392
- (0, import_vitest.test)("nested objects", function() {
393
- const date = new Date();
394
- const data = {
395
- item: {
396
- createdAt: date.getTime(),
397
- creator: {
398
- firstName: "John"
399
- }
400
- }
401
- };
402
- const selection = {
403
- item: {
404
- type: "TodoItem",
405
- keyRaw: "item",
406
- fields: {
407
- createdAt: {
408
- type: "DateTime",
409
- keyRaw: "createdAt"
410
- },
411
- creator: {
412
- type: "User",
413
- keyRaw: "creator",
414
- fields: {
415
- firstName: {
416
- type: "String",
417
- keyRaw: "firstName"
418
- }
419
- },
420
- list: {
421
- name: "All_Items",
422
- type: "User",
423
- connection: false
424
- }
425
- }
426
- }
427
- }
428
- };
429
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
430
- item: {
431
- createdAt: date,
432
- creator: {
433
- firstName: "John"
434
- }
435
- }
436
- });
437
- });
438
- (0, import_vitest.test)("fields on root", function() {
439
- const data = {
440
- rootBool: true
441
- };
442
- const selection = {
443
- rootBool: {
444
- type: "Boolean",
445
- keyRaw: "rootBool"
446
- }
447
- };
448
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
449
- rootBool: true
450
- });
451
- });
452
- (0, import_vitest.test)("enums", function() {
453
- const data = {
454
- enumValue: "Hello"
455
- };
456
- const selection = {
457
- enumValue: {
458
- type: "EnumValue",
459
- keyRaw: "enumValue"
460
- }
461
- };
462
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
463
- enumValue: "Hello"
464
- });
465
- });
466
- (0, import_vitest.test)("list of enums", function() {
467
- const data = {
468
- enumValue: ["Hello", "World"]
469
- };
470
- const selection = {
471
- enumValue: {
472
- type: "EnumValue",
473
- keyRaw: "enumValue"
474
- }
475
- };
476
- (0, import_vitest.expect)((0, import_scalars.unmarshalSelection)((0, import_test.testConfigFile)(), selection, data)).toEqual({
477
- enumValue: ["Hello", "World"]
478
- });
479
- });
480
- });
481
- (0, import_vitest.describe)("marshal selection", function() {
482
- (0, import_vitest.test)("list of objects", async function() {
483
- const date = new Date();
484
- const data = {
485
- items: [
486
- {
487
- createdAt: date,
488
- creator: {
489
- firstName: "John"
490
- }
491
- }
492
- ]
493
- };
494
- await (0, import_vitest.expect)(
495
- (0, import_scalars.marshalSelection)({
496
- selection: artifact.selection,
497
- data
498
- })
499
- ).resolves.toEqual({
500
- items: [
501
- {
502
- createdAt: date.getTime(),
503
- creator: {
504
- firstName: "John"
505
- }
506
- }
507
- ]
508
- });
509
- });
510
- (0, import_vitest.test)("list of scalars", async function() {
511
- const date1 = new Date(1);
512
- const date2 = new Date(2);
513
- const data = {
514
- items: [
515
- {
516
- dates: [date1, date2]
517
- }
518
- ]
519
- };
520
- await (0, import_vitest.expect)(
521
- (0, import_scalars.marshalSelection)({
522
- selection: artifact.selection,
523
- data
524
- })
525
- ).resolves.toEqual({
526
- items: [
527
- {
528
- dates: [date1.getTime(), date2.getTime()]
529
- }
530
- ]
531
- });
532
- });
533
- (0, import_vitest.test)("empty list of scalars", async function() {
534
- const data = {
535
- items: [
536
- {
537
- dates: []
538
- }
539
- ]
540
- };
541
- await (0, import_vitest.expect)(
542
- (0, import_scalars.marshalSelection)({
543
- selection: artifact.selection,
544
- data
545
- })
546
- ).resolves.toEqual({
547
- items: [
548
- {
549
- dates: []
550
- }
551
- ]
552
- });
553
- });
554
- (0, import_vitest.test)("missing marshal function", async function() {
555
- (0, import_config.setMockConfig)(
556
- (0, import_test.testConfigFile)({
557
- scalars: {
558
- DateTime: {
559
- type: "Date"
560
- }
561
- }
562
- })
563
- );
564
- const data = {
565
- items: [
566
- {
567
- dates: [new Date()]
568
- }
569
- ]
570
- };
571
- await (0, import_vitest.expect)(
572
- () => (0, import_scalars.marshalSelection)({
573
- selection: artifact.selection,
574
- data
575
- })
576
- ).rejects.toThrow(/scalar type DateTime is missing a `marshal` function/);
577
- });
578
- (0, import_vitest.test)("undefined", async function() {
579
- const data = {
580
- item: void 0
581
- };
582
- const selection = {
583
- item: {
584
- type: "TodoItem",
585
- keyRaw: "item",
586
- fields: {
587
- createdAt: {
588
- type: "DateTime",
589
- keyRaw: "createdAt"
590
- }
591
- }
592
- }
593
- };
594
- await (0, import_vitest.expect)(
595
- (0, import_scalars.marshalSelection)({
596
- selection,
597
- data
598
- })
599
- ).resolves.toEqual({
600
- item: void 0
601
- });
602
- });
603
- (0, import_vitest.test)("null", async function() {
604
- const data = {
605
- item: null
606
- };
607
- const selection = {
608
- item: {
609
- type: "TodoItem",
610
- keyRaw: "item",
611
- fields: {
612
- createdAt: {
613
- type: "DateTime",
614
- keyRaw: "createdAt"
615
- }
616
- }
617
- }
618
- };
619
- await (0, import_vitest.expect)(
620
- (0, import_scalars.marshalSelection)({
621
- selection,
622
- data
623
- })
624
- ).resolves.toEqual({
625
- item: null
626
- });
627
- });
628
- (0, import_vitest.test)("nested objects", async function() {
629
- const date = new Date();
630
- const data = {
631
- item: {
632
- createdAt: date,
633
- creator: {
634
- firstName: "John"
635
- }
636
- }
637
- };
638
- const selection = {
639
- item: {
640
- type: "TodoItem",
641
- keyRaw: "item",
642
- fields: {
643
- createdAt: {
644
- type: "DateTime",
645
- keyRaw: "createdAt"
646
- },
647
- creator: {
648
- type: "User",
649
- keyRaw: "creator",
650
- fields: {
651
- firstName: {
652
- type: "String",
653
- keyRaw: "firstName"
654
- }
655
- },
656
- list: {
657
- name: "All_Items",
658
- type: "User",
659
- connection: false
660
- }
661
- }
662
- }
663
- }
664
- };
665
- await (0, import_vitest.expect)(
666
- (0, import_scalars.marshalSelection)({
667
- selection,
668
- data
669
- })
670
- ).resolves.toEqual({
671
- item: {
672
- createdAt: date.getTime(),
673
- creator: {
674
- firstName: "John"
675
- }
676
- }
677
- });
678
- });
679
- (0, import_vitest.test)("fields on root", async function() {
680
- const data = {
681
- rootBool: true
682
- };
683
- const selection = {
684
- rootBool: {
685
- type: "Boolean",
686
- keyRaw: "rootBool"
687
- }
688
- };
689
- await (0, import_vitest.expect)(
690
- (0, import_scalars.marshalSelection)({
691
- selection,
692
- data
693
- })
694
- ).resolves.toEqual({
695
- rootBool: true
696
- });
697
- });
698
- (0, import_vitest.test)("enums", async function() {
699
- const data = {
700
- enumValue: "Hello"
701
- };
702
- const selection = {
703
- enumValue: {
704
- type: "EnumValue",
705
- keyRaw: "enumValue"
706
- }
707
- };
708
- await (0, import_vitest.expect)(
709
- (0, import_scalars.marshalSelection)({
710
- selection,
711
- data
712
- })
713
- ).resolves.toEqual({
714
- enumValue: "Hello"
715
- });
716
- });
717
- (0, import_vitest.test)("list of enums", async function() {
718
- const data = {
719
- enumValue: ["Hello", "World"]
720
- };
721
- const selection = {
722
- enumValue: {
723
- type: "EnumValue",
724
- keyRaw: "enumValue"
725
- }
726
- };
727
- await (0, import_vitest.expect)(
728
- (0, import_scalars.marshalSelection)({
729
- selection,
730
- data
731
- })
732
- ).resolves.toEqual({
733
- enumValue: ["Hello", "World"]
734
- });
735
- });
736
- });