houdini 0.17.7 → 0.17.9
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.
- package/.turbo/turbo-compile.log +2 -2
- package/.turbo/turbo-typedefs.log +2 -2
- package/CHANGELOG.md +9 -1
- package/build/cmd-cjs/index.js +124 -38
- package/build/cmd-esm/index.js +124 -38
- package/build/codegen-cjs/index.js +112 -36
- package/build/codegen-esm/index.js +112 -36
- package/build/lib/config.d.ts +3 -0
- package/build/lib-cjs/index.js +31 -12
- package/build/lib-esm/index.js +31 -12
- package/build/runtime/cache/cache.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +1 -1
- package/build/runtime/lib/config.d.ts +10 -2
- package/build/runtime/lib/types.d.ts +1 -0
- package/build/runtime-cjs/cache/cache.d.ts +1 -1
- package/build/runtime-cjs/cache/cache.js +6 -6
- package/build/runtime-cjs/cache/lists.d.ts +1 -1
- package/build/runtime-cjs/cache/lists.js +15 -6
- package/build/runtime-cjs/cache/tests/list.test.js +160 -70
- package/build/runtime-cjs/lib/config.d.ts +10 -2
- package/build/runtime-cjs/lib/types.d.ts +1 -0
- package/build/runtime-esm/cache/cache.d.ts +1 -1
- package/build/runtime-esm/cache/cache.js +6 -6
- package/build/runtime-esm/cache/lists.d.ts +1 -1
- package/build/runtime-esm/cache/lists.js +15 -6
- package/build/runtime-esm/cache/tests/list.test.js +160 -70
- package/build/runtime-esm/lib/config.d.ts +10 -2
- package/build/runtime-esm/lib/types.d.ts +1 -0
- package/build/test-cjs/index.js +122 -36
- package/build/test-esm/index.js +122 -36
- package/build/vite-cjs/index.js +122 -36
- package/build/vite-esm/index.js +122 -36
- package/package.json +1 -1
- package/src/codegen/generators/artifacts/artifacts.test.ts +268 -0
- package/src/codegen/generators/artifacts/operations.ts +31 -13
- package/src/codegen/generators/definitions/schema.test.ts +9 -0
- package/src/codegen/transforms/list.ts +0 -1
- package/src/codegen/transforms/paginate.test.ts +47 -0
- package/src/codegen/transforms/paginate.ts +28 -8
- package/src/codegen/transforms/schema.ts +5 -0
- package/src/codegen/validators/typeCheck.test.ts +56 -0
- package/src/codegen/validators/typeCheck.ts +66 -11
- package/src/lib/config.ts +11 -0
- package/src/runtime/cache/cache.ts +9 -6
- package/src/runtime/cache/lists.ts +24 -10
- package/src/runtime/cache/tests/list.test.ts +173 -66
- package/src/runtime/lib/config.ts +12 -2
- package/src/runtime/lib/types.ts +1 -0
|
@@ -1408,11 +1408,7 @@ test("append operation", function() {
|
|
|
1408
1408
|
operations: [
|
|
1409
1409
|
{
|
|
1410
1410
|
action: "insert",
|
|
1411
|
-
list: "All_Users"
|
|
1412
|
-
parentID: {
|
|
1413
|
-
kind: "String",
|
|
1414
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1415
|
-
}
|
|
1411
|
+
list: "All_Users"
|
|
1416
1412
|
}
|
|
1417
1413
|
],
|
|
1418
1414
|
fields: {
|
|
@@ -1429,7 +1425,7 @@ test("append operation", function() {
|
|
|
1429
1425
|
}
|
|
1430
1426
|
}
|
|
1431
1427
|
});
|
|
1432
|
-
expect([...cache.list("All_Users",
|
|
1428
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(1);
|
|
1433
1429
|
});
|
|
1434
1430
|
test("append from list", function() {
|
|
1435
1431
|
const cache = new Cache(config);
|
|
@@ -1489,11 +1485,7 @@ test("append from list", function() {
|
|
|
1489
1485
|
operations: [
|
|
1490
1486
|
{
|
|
1491
1487
|
action: "insert",
|
|
1492
|
-
list: "All_Users"
|
|
1493
|
-
parentID: {
|
|
1494
|
-
kind: "String",
|
|
1495
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1496
|
-
}
|
|
1488
|
+
list: "All_Users"
|
|
1497
1489
|
}
|
|
1498
1490
|
],
|
|
1499
1491
|
fields: {
|
|
@@ -1508,7 +1500,7 @@ test("append from list", function() {
|
|
|
1508
1500
|
newUser: [{ id: "3" }, { id: "4" }]
|
|
1509
1501
|
}
|
|
1510
1502
|
});
|
|
1511
|
-
expect([...cache.list("All_Users",
|
|
1503
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(2);
|
|
1512
1504
|
});
|
|
1513
1505
|
test("toggle list", function() {
|
|
1514
1506
|
const cache = new Cache(config);
|
|
@@ -1587,11 +1579,7 @@ test("toggle list", function() {
|
|
|
1587
1579
|
operations: [
|
|
1588
1580
|
{
|
|
1589
1581
|
action: "toggle",
|
|
1590
|
-
list: "All_Users"
|
|
1591
|
-
parentID: {
|
|
1592
|
-
kind: "String",
|
|
1593
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1594
|
-
}
|
|
1582
|
+
list: "All_Users"
|
|
1595
1583
|
}
|
|
1596
1584
|
],
|
|
1597
1585
|
fields: {
|
|
@@ -1603,19 +1591,11 @@ test("toggle list", function() {
|
|
|
1603
1591
|
}
|
|
1604
1592
|
};
|
|
1605
1593
|
cache.write({ selection: toggleSelection, data: { newUser: { id: "3" } } });
|
|
1606
|
-
expect([...cache.list("All_Users",
|
|
1607
|
-
"User:5",
|
|
1608
|
-
"User:3"
|
|
1609
|
-
]);
|
|
1594
|
+
expect([...cache.list("All_Users", "1")]).toEqual(["User:5", "User:3"]);
|
|
1610
1595
|
cache.write({ selection: toggleSelection, data: { newUser: { id: "3" } } });
|
|
1611
|
-
expect([...cache.list("All_Users",
|
|
1612
|
-
"User:5"
|
|
1613
|
-
]);
|
|
1596
|
+
expect([...cache.list("All_Users", "1")]).toEqual(["User:5"]);
|
|
1614
1597
|
cache.write({ selection: toggleSelection, data: { newUser: { id: "3" } } });
|
|
1615
|
-
expect([...cache.list("All_Users",
|
|
1616
|
-
"User:5",
|
|
1617
|
-
"User:3"
|
|
1618
|
-
]);
|
|
1598
|
+
expect([...cache.list("All_Users", "1")]).toEqual(["User:5", "User:3"]);
|
|
1619
1599
|
});
|
|
1620
1600
|
test("append when operation", function() {
|
|
1621
1601
|
const cache = new Cache(config);
|
|
@@ -1682,10 +1662,6 @@ test("append when operation", function() {
|
|
|
1682
1662
|
{
|
|
1683
1663
|
action: "insert",
|
|
1684
1664
|
list: "All_Users",
|
|
1685
|
-
parentID: {
|
|
1686
|
-
kind: "String",
|
|
1687
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1688
|
-
},
|
|
1689
1665
|
when: {
|
|
1690
1666
|
must: {
|
|
1691
1667
|
value: "not-foo"
|
|
@@ -1707,7 +1683,7 @@ test("append when operation", function() {
|
|
|
1707
1683
|
}
|
|
1708
1684
|
}
|
|
1709
1685
|
});
|
|
1710
|
-
expect([...cache.list("All_Users",
|
|
1686
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
1711
1687
|
});
|
|
1712
1688
|
test("prepend when operation", function() {
|
|
1713
1689
|
const cache = new Cache(config);
|
|
@@ -1774,10 +1750,6 @@ test("prepend when operation", function() {
|
|
|
1774
1750
|
{
|
|
1775
1751
|
action: "insert",
|
|
1776
1752
|
list: "All_Users",
|
|
1777
|
-
parentID: {
|
|
1778
|
-
kind: "String",
|
|
1779
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1780
|
-
},
|
|
1781
1753
|
position: "first",
|
|
1782
1754
|
when: {
|
|
1783
1755
|
must: {
|
|
@@ -1800,7 +1772,7 @@ test("prepend when operation", function() {
|
|
|
1800
1772
|
}
|
|
1801
1773
|
}
|
|
1802
1774
|
});
|
|
1803
|
-
expect([...cache.list("All_Users",
|
|
1775
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
1804
1776
|
});
|
|
1805
1777
|
test("prepend operation", function() {
|
|
1806
1778
|
const cache = new Cache(config);
|
|
@@ -1881,10 +1853,6 @@ test("prepend operation", function() {
|
|
|
1881
1853
|
{
|
|
1882
1854
|
action: "insert",
|
|
1883
1855
|
list: "All_Users",
|
|
1884
|
-
parentID: {
|
|
1885
|
-
kind: "String",
|
|
1886
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1887
|
-
},
|
|
1888
1856
|
position: "first"
|
|
1889
1857
|
}
|
|
1890
1858
|
],
|
|
@@ -1902,10 +1870,7 @@ test("prepend operation", function() {
|
|
|
1902
1870
|
}
|
|
1903
1871
|
}
|
|
1904
1872
|
});
|
|
1905
|
-
expect([...cache.list("All_Users",
|
|
1906
|
-
"User:3",
|
|
1907
|
-
"User:2"
|
|
1908
|
-
]);
|
|
1873
|
+
expect([...cache.list("All_Users", "1")]).toEqual(["User:3", "User:2"]);
|
|
1909
1874
|
});
|
|
1910
1875
|
test("remove operation", function() {
|
|
1911
1876
|
const cache = new Cache(config);
|
|
@@ -1980,11 +1945,7 @@ test("remove operation", function() {
|
|
|
1980
1945
|
operations: [
|
|
1981
1946
|
{
|
|
1982
1947
|
action: "remove",
|
|
1983
|
-
list: "All_Users"
|
|
1984
|
-
parentID: {
|
|
1985
|
-
kind: "String",
|
|
1986
|
-
value: cache._internal_unstable.id("User", "1")
|
|
1987
|
-
}
|
|
1948
|
+
list: "All_Users"
|
|
1988
1949
|
}
|
|
1989
1950
|
],
|
|
1990
1951
|
fields: {
|
|
@@ -2001,7 +1962,7 @@ test("remove operation", function() {
|
|
|
2001
1962
|
}
|
|
2002
1963
|
}
|
|
2003
1964
|
});
|
|
2004
|
-
expect([...cache.list("All_Users",
|
|
1965
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
2005
1966
|
});
|
|
2006
1967
|
test("remove operation from list", function() {
|
|
2007
1968
|
const cache = new Cache(config);
|
|
@@ -2079,11 +2040,7 @@ test("remove operation from list", function() {
|
|
|
2079
2040
|
operations: [
|
|
2080
2041
|
{
|
|
2081
2042
|
action: "remove",
|
|
2082
|
-
list: "All_Users"
|
|
2083
|
-
parentID: {
|
|
2084
|
-
kind: "String",
|
|
2085
|
-
value: cache._internal_unstable.id("User", "1")
|
|
2086
|
-
}
|
|
2043
|
+
list: "All_Users"
|
|
2087
2044
|
}
|
|
2088
2045
|
],
|
|
2089
2046
|
fields: {
|
|
@@ -2098,7 +2055,7 @@ test("remove operation from list", function() {
|
|
|
2098
2055
|
newUser: [{ id: "2" }, { id: "3" }]
|
|
2099
2056
|
}
|
|
2100
2057
|
});
|
|
2101
|
-
expect([...cache.list("All_Users",
|
|
2058
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
2102
2059
|
});
|
|
2103
2060
|
test("delete operation", function() {
|
|
2104
2061
|
const cache = new Cache(config);
|
|
@@ -2190,7 +2147,7 @@ test("delete operation", function() {
|
|
|
2190
2147
|
}
|
|
2191
2148
|
}
|
|
2192
2149
|
});
|
|
2193
|
-
expect([...cache.list("All_Users",
|
|
2150
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
2194
2151
|
expect(cache._internal_unstable.storage.topLayer.operations["User:2"].deleted).toBeTruthy();
|
|
2195
2152
|
});
|
|
2196
2153
|
test("delete operation from list", function() {
|
|
@@ -2286,7 +2243,7 @@ test("delete operation from list", function() {
|
|
|
2286
2243
|
}
|
|
2287
2244
|
}
|
|
2288
2245
|
});
|
|
2289
|
-
expect([...cache.list("All_Users",
|
|
2246
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
2290
2247
|
expect(cache._internal_unstable.storage.topLayer.operations["User:2"].deleted).toBeTruthy();
|
|
2291
2248
|
expect(cache._internal_unstable.storage.topLayer.operations["User:3"].deleted).toBeTruthy();
|
|
2292
2249
|
});
|
|
@@ -2421,7 +2378,7 @@ test("delete operation from connection", function() {
|
|
|
2421
2378
|
}
|
|
2422
2379
|
}
|
|
2423
2380
|
});
|
|
2424
|
-
expect([...cache.list("All_Users",
|
|
2381
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
2425
2382
|
expect(cache._internal_unstable.storage.topLayer.operations["User:2"].deleted).toBeTruthy();
|
|
2426
2383
|
});
|
|
2427
2384
|
test("disabled linked lists update", function() {
|
|
@@ -2832,11 +2789,7 @@ test("list operations fail silently", function() {
|
|
|
2832
2789
|
operations: [
|
|
2833
2790
|
{
|
|
2834
2791
|
action: "insert",
|
|
2835
|
-
list: "All_Users"
|
|
2836
|
-
parentID: {
|
|
2837
|
-
kind: "String",
|
|
2838
|
-
value: cache._internal_unstable.id("User", "1")
|
|
2839
|
-
}
|
|
2792
|
+
list: "All_Users"
|
|
2840
2793
|
}
|
|
2841
2794
|
],
|
|
2842
2795
|
fields: {
|
|
@@ -3049,10 +3002,66 @@ test("parentID must be passed if there are multiple instances of a list handler"
|
|
|
3049
3002
|
},
|
|
3050
3003
|
{}
|
|
3051
3004
|
);
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3005
|
+
const writeSelectionNoParentID = {
|
|
3006
|
+
user: {
|
|
3007
|
+
type: "User",
|
|
3008
|
+
keyRaw: "user",
|
|
3009
|
+
operations: [
|
|
3010
|
+
{
|
|
3011
|
+
action: "insert",
|
|
3012
|
+
list: "All_Users"
|
|
3013
|
+
}
|
|
3014
|
+
],
|
|
3015
|
+
fields: {
|
|
3016
|
+
id: {
|
|
3017
|
+
type: "ID",
|
|
3018
|
+
keyRaw: "id"
|
|
3019
|
+
},
|
|
3020
|
+
firstName: {
|
|
3021
|
+
type: "String",
|
|
3022
|
+
keyRaw: "firstName"
|
|
3023
|
+
}
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
};
|
|
3027
|
+
const writeSelectionWithParentID = {
|
|
3028
|
+
user: {
|
|
3029
|
+
type: "User",
|
|
3030
|
+
keyRaw: "user",
|
|
3031
|
+
operations: [
|
|
3032
|
+
{
|
|
3033
|
+
action: "insert",
|
|
3034
|
+
list: "All_Users",
|
|
3035
|
+
parentID: {
|
|
3036
|
+
kind: "String",
|
|
3037
|
+
value: "1"
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
],
|
|
3041
|
+
fields: {
|
|
3042
|
+
id: {
|
|
3043
|
+
type: "ID",
|
|
3044
|
+
keyRaw: "id"
|
|
3045
|
+
},
|
|
3046
|
+
firstName: {
|
|
3047
|
+
type: "String",
|
|
3048
|
+
keyRaw: "firstName"
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
cache.write({
|
|
3054
|
+
selection: writeSelectionNoParentID,
|
|
3055
|
+
data: { user: { id: "2", firstName: "test" } }
|
|
3056
|
+
});
|
|
3057
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(1);
|
|
3058
|
+
expect([...cache.list("All_Users", "2")]).toHaveLength(0);
|
|
3059
|
+
cache.write({
|
|
3060
|
+
selection: writeSelectionWithParentID,
|
|
3061
|
+
data: { user: { id: "2", firstName: "test" } }
|
|
3062
|
+
});
|
|
3063
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(2);
|
|
3064
|
+
expect([...cache.list("All_Users", "2")]).toHaveLength(0);
|
|
3056
3065
|
});
|
|
3057
3066
|
test("append in abstract list", function() {
|
|
3058
3067
|
const cache = new Cache(config);
|
|
@@ -3297,3 +3306,84 @@ test("list operations on interface fields without a well defined parent update t
|
|
|
3297
3306
|
}
|
|
3298
3307
|
});
|
|
3299
3308
|
});
|
|
3309
|
+
test("parentID ignores single lists that don't match", function() {
|
|
3310
|
+
const cache = new Cache(config);
|
|
3311
|
+
cache.write({
|
|
3312
|
+
selection: {
|
|
3313
|
+
viewer: {
|
|
3314
|
+
type: "User",
|
|
3315
|
+
keyRaw: "viewer",
|
|
3316
|
+
fields: {
|
|
3317
|
+
id: {
|
|
3318
|
+
type: "ID",
|
|
3319
|
+
keyRaw: "id"
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
},
|
|
3324
|
+
data: {
|
|
3325
|
+
viewer: {
|
|
3326
|
+
id: "1"
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
});
|
|
3330
|
+
cache.subscribe(
|
|
3331
|
+
{
|
|
3332
|
+
rootType: "User",
|
|
3333
|
+
selection: {
|
|
3334
|
+
friends: {
|
|
3335
|
+
type: "User",
|
|
3336
|
+
keyRaw: "friends",
|
|
3337
|
+
list: {
|
|
3338
|
+
name: "All_Users",
|
|
3339
|
+
connection: false,
|
|
3340
|
+
type: "User"
|
|
3341
|
+
},
|
|
3342
|
+
fields: {
|
|
3343
|
+
id: {
|
|
3344
|
+
type: "ID",
|
|
3345
|
+
keyRaw: "id"
|
|
3346
|
+
},
|
|
3347
|
+
firstName: {
|
|
3348
|
+
type: "String",
|
|
3349
|
+
keyRaw: "firstName"
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
},
|
|
3354
|
+
parentID: cache._internal_unstable.id("User", "1"),
|
|
3355
|
+
set: vi.fn()
|
|
3356
|
+
},
|
|
3357
|
+
{}
|
|
3358
|
+
);
|
|
3359
|
+
cache.write({
|
|
3360
|
+
selection: {
|
|
3361
|
+
newUser: {
|
|
3362
|
+
type: "User",
|
|
3363
|
+
keyRaw: "newUser",
|
|
3364
|
+
operations: [
|
|
3365
|
+
{
|
|
3366
|
+
action: "insert",
|
|
3367
|
+
list: "All_Users",
|
|
3368
|
+
parentID: {
|
|
3369
|
+
kind: "String",
|
|
3370
|
+
value: "2"
|
|
3371
|
+
}
|
|
3372
|
+
}
|
|
3373
|
+
],
|
|
3374
|
+
fields: {
|
|
3375
|
+
id: {
|
|
3376
|
+
type: "ID",
|
|
3377
|
+
keyRaw: "id"
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
},
|
|
3382
|
+
data: {
|
|
3383
|
+
newUser: {
|
|
3384
|
+
id: "3"
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
});
|
|
3388
|
+
expect([...cache.list("All_Users", "1")]).toHaveLength(0);
|
|
3389
|
+
});
|
|
@@ -45,12 +45,12 @@ export declare type ConfigFile = {
|
|
|
45
45
|
*/
|
|
46
46
|
definitionsPath?: string;
|
|
47
47
|
/**
|
|
48
|
-
* One of "kit" or "svelte". Used to tell the preprocessor what kind of loading paradigm to generate for you. (default: kit)
|
|
48
|
+
* One of "kit" or "svelte". Used to tell the preprocessor what kind of loading paradigm to generate for you. (default: `kit`)
|
|
49
49
|
* @deprecated please follow the steps here: http://www.houdinigraphql.com/guides/release-notes#0170
|
|
50
50
|
*/
|
|
51
51
|
framework?: 'kit' | 'svelte';
|
|
52
52
|
/**
|
|
53
|
-
* One of "esm" or "commonjs". Tells the artifact generator what kind of modules to create. (default: esm)
|
|
53
|
+
* One of "esm" or "commonjs". Tells the artifact generator what kind of modules to create. (default: `esm`)
|
|
54
54
|
*/
|
|
55
55
|
module?: 'esm' | 'commonjs';
|
|
56
56
|
/**
|
|
@@ -65,6 +65,14 @@ export declare type ConfigFile = {
|
|
|
65
65
|
* Specifies whether or not the cache should always use partial data. For more information: https://www.houdinigraphql.com/guides/caching-data#partial-data
|
|
66
66
|
*/
|
|
67
67
|
defaultPartial?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Specifies whether mutations should append or prepend list. For more information: https://www.houdinigraphql.com/api/graphql (default: `append`)
|
|
70
|
+
*/
|
|
71
|
+
defaultListPosition?: 'append' | 'prepend';
|
|
72
|
+
/**
|
|
73
|
+
* Specifies whether mutation should apply a specific target list. When you set `all`, it's like adding the directive `@allLists` to all _insert fragment (default: `null`)
|
|
74
|
+
*/
|
|
75
|
+
defaultListTarget?: 'all' | null;
|
|
68
76
|
/**
|
|
69
77
|
* A list of fields to use when computing a record’s id. The default value is ['id']. For more information: https://www.houdinigraphql.com/guides/caching-data#custom-ids
|
|
70
78
|
*/
|