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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "0.17.13",
3
+ "version": "0.18.0",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -23,7 +23,7 @@
23
23
  "prettier": "^2.5.1",
24
24
  "rollup": "^2.79.1",
25
25
  "turbo": "^1.5.4",
26
- "vite": "^3.1.6",
26
+ "vite": "^3.2.4",
27
27
  "vitest": "^0.23.4",
28
28
  "scripts": "^1.0.0"
29
29
  },
@@ -1,357 +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)("not partial", function() {
7
- const cache = new import_cache.Cache(config);
8
- const selection = {
9
- viewer: {
10
- type: "User",
11
- keyRaw: "viewer",
12
- fields: {
13
- id: {
14
- type: "ID",
15
- keyRaw: "id"
16
- },
17
- firstName: {
18
- type: "String",
19
- keyRaw: "firstName"
20
- },
21
- friends: {
22
- type: "User",
23
- keyRaw: "friends",
24
- nullable: true,
25
- fields: {
26
- id: {
27
- type: "ID",
28
- keyRaw: "id"
29
- },
30
- firstName: {
31
- type: "String",
32
- keyRaw: "firstName"
33
- }
34
- }
35
- }
36
- }
37
- }
38
- };
39
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
40
- data: null,
41
- partial: false
42
- });
43
- cache.write({
44
- selection,
45
- data: {
46
- viewer: {
47
- id: "1",
48
- firstName: "bob",
49
- friends: [
50
- {
51
- id: "2",
52
- firstName: "jane"
53
- },
54
- null
55
- ]
56
- }
57
- }
58
- });
59
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
60
- partial: false
61
- });
62
- });
63
- (0, import_vitest.test)("not partial with empty list", function() {
64
- const cache = new import_cache.Cache(config);
65
- const selection = {
66
- viewer: {
67
- type: "User",
68
- keyRaw: "viewer",
69
- fields: {
70
- id: {
71
- type: "ID",
72
- keyRaw: "id"
73
- },
74
- firstName: {
75
- type: "String",
76
- keyRaw: "firstName"
77
- },
78
- friends: {
79
- type: "User",
80
- keyRaw: "friends",
81
- fields: {
82
- id: {
83
- type: "ID",
84
- keyRaw: "id"
85
- },
86
- firstName: {
87
- type: "String",
88
- keyRaw: "firstName"
89
- }
90
- }
91
- }
92
- }
93
- }
94
- };
95
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
96
- data: null,
97
- partial: false
98
- });
99
- cache.write({
100
- selection,
101
- data: {
102
- viewer: {
103
- id: "1",
104
- firstName: "bob",
105
- friends: []
106
- }
107
- }
108
- });
109
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
110
- partial: false
111
- });
112
- });
113
- (0, import_vitest.test)("partial with missing linked record", function() {
114
- const cache = new import_cache.Cache(config);
115
- const selection = {
116
- viewer: {
117
- type: "User",
118
- keyRaw: "viewer",
119
- fields: {
120
- id: {
121
- type: "ID",
122
- keyRaw: "id"
123
- },
124
- firstName: {
125
- type: "String",
126
- keyRaw: "firstName"
127
- },
128
- parent: {
129
- type: "User",
130
- keyRaw: "parent",
131
- fields: {
132
- id: {
133
- type: "ID",
134
- keyRaw: "id"
135
- },
136
- firstName: {
137
- type: "String",
138
- keyRaw: "firstName"
139
- }
140
- }
141
- }
142
- }
143
- }
144
- };
145
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
146
- data: null,
147
- partial: false
148
- });
149
- cache.write({
150
- selection,
151
- data: {
152
- viewer: {
153
- id: "1",
154
- firstName: "bob"
155
- }
156
- }
157
- });
158
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
159
- partial: true
160
- });
161
- });
162
- (0, import_vitest.test)("partial with missing single field", function() {
163
- const cache = new import_cache.Cache(config);
164
- const selection = {
165
- viewer: {
166
- type: "User",
167
- keyRaw: "viewer",
168
- fields: {
169
- id: {
170
- type: "ID",
171
- keyRaw: "id"
172
- },
173
- firstName: {
174
- type: "String",
175
- keyRaw: "firstName"
176
- },
177
- friends: {
178
- type: "User",
179
- keyRaw: "friends",
180
- fields: {
181
- id: {
182
- type: "ID",
183
- keyRaw: "id"
184
- },
185
- firstName: {
186
- type: "String",
187
- keyRaw: "firstName"
188
- }
189
- }
190
- }
191
- }
192
- }
193
- };
194
- cache.write({
195
- selection,
196
- data: {
197
- viewer: {
198
- id: "1",
199
- friends: []
200
- }
201
- }
202
- });
203
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
204
- partial: true
205
- });
206
- });
207
- (0, import_vitest.test)("partial missing data inside of linked list", function() {
208
- const cache = new import_cache.Cache(config);
209
- const selection = {
210
- viewer: {
211
- type: "User",
212
- keyRaw: "viewer",
213
- fields: {
214
- id: {
215
- type: "ID",
216
- keyRaw: "id"
217
- },
218
- friends: {
219
- type: "User",
220
- keyRaw: "friends",
221
- fields: {
222
- id: {
223
- type: "ID",
224
- keyRaw: "id"
225
- },
226
- firstName: {
227
- type: "String",
228
- keyRaw: "firstName"
229
- }
230
- }
231
- }
232
- }
233
- }
234
- };
235
- cache.write({
236
- selection,
237
- data: {
238
- viewer: {
239
- id: "1",
240
- friends: [{ id: "2", firstName: "anthony" }, { id: "3" }]
241
- }
242
- }
243
- });
244
- (0, import_vitest.expect)(cache.read({ selection })).toMatchObject({
245
- partial: true
246
- });
247
- });
248
- (0, import_vitest.test)("missing cursor of item in connection from operation should not trigger null cascade", function() {
249
- const cache = new import_cache.Cache(config);
250
- const selection = {
251
- viewer: {
252
- type: "User",
253
- keyRaw: "viewer",
254
- fields: {
255
- id: {
256
- type: "ID",
257
- keyRaw: "id"
258
- },
259
- friends: {
260
- type: "User",
261
- keyRaw: "friends",
262
- list: {
263
- name: "All_Users",
264
- connection: true,
265
- type: "User"
266
- },
267
- fields: {
268
- edges: {
269
- type: "UserEdge",
270
- keyRaw: "edges",
271
- fields: {
272
- cursor: {
273
- type: "Node",
274
- keyRaw: "cursor",
275
- nullable: false
276
- },
277
- node: {
278
- type: "Node",
279
- keyRaw: "node",
280
- abstract: true,
281
- fields: {
282
- __typename: {
283
- type: "String",
284
- keyRaw: "__typename"
285
- },
286
- id: {
287
- type: "ID",
288
- keyRaw: "id"
289
- },
290
- firstName: {
291
- type: "String",
292
- keyRaw: "firstName"
293
- }
294
- }
295
- }
296
- }
297
- }
298
- }
299
- }
300
- }
301
- }
302
- };
303
- cache.write({
304
- selection,
305
- data: {
306
- viewer: {
307
- id: "1",
308
- friends: {
309
- edges: [
310
- {
311
- node: {
312
- __typename: "User",
313
- id: "2",
314
- firstName: "jane"
315
- }
316
- }
317
- ]
318
- }
319
- }
320
- }
321
- });
322
- cache.subscribe({
323
- set: import_vitest.vi.fn(),
324
- selection,
325
- rootType: "Query"
326
- });
327
- cache.list("All_Users").prepend(
328
- {
329
- __typename: {
330
- type: "String",
331
- keyRaw: "__typename"
332
- },
333
- id: {
334
- type: "ID",
335
- keyRaw: "id"
336
- },
337
- firstName: {
338
- type: "String",
339
- keyRaw: "firstName"
340
- }
341
- },
342
- {
343
- __typename: "User",
344
- id: "2",
345
- firstName: "Sally"
346
- }
347
- );
348
- (0, import_vitest.expect)(cache.read({ selection })).not.toMatchObject({
349
- data: {
350
- viewer: {
351
- friends: {
352
- edges: import_vitest.expect.arrayContaining([null])
353
- }
354
- }
355
- }
356
- });
357
- });
@@ -1,271 +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
- config.cacheBufferSize = 10;
7
- (0, import_vitest.test)("adequate ticks of garbage collector clear unsubscribed data", function() {
8
- const cache = new import_cache.Cache(config);
9
- const userFields = {
10
- id: {
11
- type: "ID",
12
- keyRaw: "id"
13
- },
14
- firstName: {
15
- type: "String",
16
- keyRaw: "firstName"
17
- }
18
- };
19
- cache.write({
20
- selection: {
21
- viewer: {
22
- type: "User",
23
- keyRaw: "viewer",
24
- fields: userFields
25
- }
26
- },
27
- data: {
28
- viewer: {
29
- id: "1",
30
- firstName: "bob"
31
- }
32
- }
33
- });
34
- for (const _ of Array.from({ length: config.cacheBufferSize })) {
35
- cache._internal_unstable.collectGarbage();
36
- (0, import_vitest.expect)(cache.read({ selection: userFields, parent: "User:1" })).toMatchObject({
37
- data: { id: "1" }
38
- });
39
- }
40
- cache._internal_unstable.collectGarbage();
41
- (0, import_vitest.expect)(cache.read({ selection: userFields, parent: "User:1" })).toMatchObject({
42
- data: null
43
- });
44
- });
45
- (0, import_vitest.test)("subscribed data shouldn't be garbage collected", function() {
46
- const cache = new import_cache.Cache((0, import_test.testConfigFile)());
47
- cache.write({
48
- selection: {
49
- viewer: {
50
- type: "User",
51
- keyRaw: "viewer",
52
- fields: {
53
- id: {
54
- type: "ID",
55
- keyRaw: "id"
56
- },
57
- firstName: {
58
- type: "String",
59
- keyRaw: "firstName"
60
- }
61
- }
62
- }
63
- },
64
- data: {
65
- viewer: {
66
- id: "1",
67
- firstName: "bob"
68
- }
69
- }
70
- });
71
- cache.subscribe({
72
- rootType: "Query",
73
- selection: {
74
- viewer: {
75
- type: "User",
76
- keyRaw: "viewer",
77
- fields: {
78
- id: {
79
- type: "ID",
80
- keyRaw: "id"
81
- }
82
- }
83
- }
84
- },
85
- set: import_vitest.vi.fn()
86
- });
87
- for (const _ of Array.from({ length: config.cacheBufferSize + 1 })) {
88
- cache._internal_unstable.collectGarbage();
89
- }
90
- (0, import_vitest.expect)(
91
- cache.read({
92
- selection: {
93
- id: {
94
- type: "ID",
95
- keyRaw: "id"
96
- }
97
- },
98
- parent: "User:1"
99
- }).data
100
- ).toEqual({ id: "1" });
101
- });
102
- (0, import_vitest.test)("resubscribing to fields marked for garbage collection resets counter", function() {
103
- const cache = new import_cache.Cache((0, import_test.testConfigFile)());
104
- cache.write({
105
- selection: {
106
- viewer: {
107
- type: "User",
108
- keyRaw: "viewer",
109
- fields: {
110
- id: {
111
- type: "ID",
112
- keyRaw: "id"
113
- },
114
- firstName: {
115
- type: "String",
116
- keyRaw: "firstName"
117
- }
118
- }
119
- }
120
- },
121
- data: {
122
- viewer: {
123
- id: "1",
124
- firstName: "bob"
125
- }
126
- }
127
- });
128
- for (const _ of Array.from({ length: 3 })) {
129
- cache._internal_unstable.collectGarbage();
130
- }
131
- const set = import_vitest.vi.fn();
132
- cache.subscribe({
133
- rootType: "Query",
134
- selection: {
135
- viewer: {
136
- type: "User",
137
- keyRaw: "viewer",
138
- fields: {
139
- id: {
140
- type: "ID",
141
- keyRaw: "id"
142
- }
143
- }
144
- }
145
- },
146
- set
147
- });
148
- for (const _ of Array.from({ length: config.cacheBufferSize })) {
149
- cache._internal_unstable.collectGarbage();
150
- }
151
- cache.unsubscribe({
152
- rootType: "Query",
153
- selection: {
154
- viewer: {
155
- type: "User",
156
- keyRaw: "viewer",
157
- fields: {
158
- id: {
159
- type: "ID",
160
- keyRaw: "id"
161
- }
162
- }
163
- }
164
- },
165
- set
166
- });
167
- for (const _ of Array.from({ length: config.cacheBufferSize })) {
168
- cache._internal_unstable.collectGarbage();
169
- }
170
- (0, import_vitest.expect)(
171
- cache.read({
172
- selection: {
173
- id: {
174
- type: "ID",
175
- keyRaw: "id"
176
- }
177
- },
178
- parent: "User:1"
179
- }).data
180
- ).toEqual({ id: "1" });
181
- cache._internal_unstable.collectGarbage();
182
- (0, import_vitest.expect)(
183
- cache.read({
184
- selection: {
185
- id: {
186
- type: "ID",
187
- keyRaw: "id"
188
- }
189
- },
190
- parent: "User:1"
191
- })
192
- ).toMatchObject({
193
- data: null
194
- });
195
- });
196
- (0, import_vitest.test)("ticks of gc delete list handlers", function() {
197
- const cache = new import_cache.Cache(config);
198
- const selection = {
199
- viewer: {
200
- type: "User",
201
- keyRaw: "viewer",
202
- fields: {
203
- id: {
204
- type: "ID",
205
- keyRaw: "id"
206
- },
207
- friends: {
208
- type: "User",
209
- keyRaw: "friends",
210
- list: {
211
- name: "All_Users",
212
- connection: false,
213
- type: "User"
214
- },
215
- fields: {
216
- id: {
217
- type: "ID",
218
- keyRaw: "id"
219
- },
220
- firstName: {
221
- type: "String",
222
- keyRaw: "firstName"
223
- }
224
- }
225
- }
226
- }
227
- }
228
- };
229
- cache.write({
230
- selection,
231
- variables: {
232
- var: "hello"
233
- },
234
- data: {
235
- viewer: {
236
- id: "1",
237
- friends: [
238
- {
239
- id: "2",
240
- firstName: "yves"
241
- }
242
- ]
243
- }
244
- }
245
- });
246
- const set = import_vitest.vi.fn();
247
- cache.subscribe(
248
- {
249
- rootType: "Query",
250
- set,
251
- selection
252
- },
253
- {
254
- var: "hello"
255
- }
256
- );
257
- cache.unsubscribe(
258
- {
259
- rootType: "Query",
260
- set,
261
- selection
262
- },
263
- {
264
- var: "hello"
265
- }
266
- );
267
- for (const _ of Array.from({ length: config.cacheBufferSize + 1 })) {
268
- cache._internal_unstable.collectGarbage();
269
- }
270
- (0, import_vitest.expect)(cache._internal_unstable.lists.get("All_Users")).toBeNull();
271
- });
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var import_vitest = require("vitest");
3
- var import_stuff = require("../stuff");
4
- (0, import_vitest.describe)("key evaluation", function() {
5
- const table = [
6
- {
7
- title: "string",
8
- key: "fieldName",
9
- expected: "fieldName"
10
- },
11
- {
12
- title: "variable",
13
- key: "fieldName(foo: $bar)",
14
- variables: { bar: "baz" },
15
- expected: 'fieldName(foo: "baz")'
16
- },
17
- {
18
- title: "$ in string",
19
- key: 'fieldName(foo: "$bar")',
20
- variables: { bar: "baz" },
21
- expected: 'fieldName(foo: "$bar")'
22
- },
23
- {
24
- title: "undefined variable",
25
- key: "fieldName(foo: $bar)",
26
- expected: "fieldName(foo: undefined)"
27
- }
28
- ];
29
- for (const row of table) {
30
- (0, import_vitest.test)(row.title, function() {
31
- (0, import_vitest.expect)((0, import_stuff.evaluateKey)(row.key, row.variables)).toEqual(row.expected);
32
- });
33
- }
34
- });