houdini 0.17.8 → 0.17.10
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/README.md +33 -0
- 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 +16 -1
- package/.turbo/turbo-compile.log +0 -5
- package/.turbo/turbo-typedefs.log +0 -5
- package/CHANGELOG.md +0 -367
- package/src/cmd/generate.ts +0 -54
- package/src/cmd/index.ts +0 -60
- package/src/cmd/init.ts +0 -637
- package/src/cmd/pullSchema.ts +0 -40
- package/src/codegen/generators/artifacts/artifacts.test.ts +0 -2978
- package/src/codegen/generators/artifacts/fieldKey.ts +0 -60
- package/src/codegen/generators/artifacts/index.ts +0 -330
- package/src/codegen/generators/artifacts/indexFile.ts +0 -24
- package/src/codegen/generators/artifacts/inputs.ts +0 -81
- package/src/codegen/generators/artifacts/operations.ts +0 -263
- package/src/codegen/generators/artifacts/pagination.test.ts +0 -664
- package/src/codegen/generators/artifacts/policy.test.ts +0 -298
- package/src/codegen/generators/artifacts/selection.ts +0 -208
- package/src/codegen/generators/artifacts/utils.test.ts +0 -118
- package/src/codegen/generators/artifacts/utils.ts +0 -108
- package/src/codegen/generators/definitions/enums.test.ts +0 -61
- package/src/codegen/generators/definitions/enums.ts +0 -68
- package/src/codegen/generators/definitions/index.ts +0 -11
- package/src/codegen/generators/definitions/schema.test.ts +0 -227
- package/src/codegen/generators/index.ts +0 -6
- package/src/codegen/generators/indexFile/index.ts +0 -63
- package/src/codegen/generators/indexFile/indexFile.test.ts +0 -72
- package/src/codegen/generators/persistedQueries/index.ts +0 -55
- package/src/codegen/generators/persistedQueries/persistedQuery.test.ts +0 -26
- package/src/codegen/generators/runtime/index.test.ts +0 -74
- package/src/codegen/generators/runtime/index.ts +0 -64
- package/src/codegen/generators/runtime/runtime.test.ts +0 -25
- package/src/codegen/generators/typescript/addReferencedInputTypes.ts +0 -77
- package/src/codegen/generators/typescript/index.ts +0 -412
- package/src/codegen/generators/typescript/inlineType.ts +0 -409
- package/src/codegen/generators/typescript/typeReference.ts +0 -44
- package/src/codegen/generators/typescript/types.ts +0 -81
- package/src/codegen/generators/typescript/typescript.test.ts +0 -1434
- package/src/codegen/index.ts +0 -406
- package/src/codegen/transforms/addID.test.ts +0 -93
- package/src/codegen/transforms/addID.ts +0 -86
- package/src/codegen/transforms/composeQueries.test.ts +0 -50
- package/src/codegen/transforms/composeQueries.ts +0 -154
- package/src/codegen/transforms/fragmentVariables.test.ts +0 -636
- package/src/codegen/transforms/fragmentVariables.ts +0 -417
- package/src/codegen/transforms/index.ts +0 -7
- package/src/codegen/transforms/list.ts +0 -485
- package/src/codegen/transforms/lists.test.ts +0 -530
- package/src/codegen/transforms/paginate.test.ts +0 -1481
- package/src/codegen/transforms/paginate.ts +0 -750
- package/src/codegen/transforms/schema.test.ts +0 -136
- package/src/codegen/transforms/schema.ts +0 -104
- package/src/codegen/transforms/typename.test.ts +0 -125
- package/src/codegen/transforms/typename.ts +0 -55
- package/src/codegen/utils/commonjs.ts +0 -26
- package/src/codegen/utils/flattenSelections.ts +0 -179
- package/src/codegen/utils/graphql.test.ts +0 -35
- package/src/codegen/utils/graphql.ts +0 -79
- package/src/codegen/utils/index.ts +0 -5
- package/src/codegen/utils/moduleExport.ts +0 -27
- package/src/codegen/utils/murmur.ts +0 -79
- package/src/codegen/validators/index.ts +0 -4
- package/src/codegen/validators/noIDAlias.test.ts +0 -71
- package/src/codegen/validators/noIDAlias.ts +0 -39
- package/src/codegen/validators/plugins.ts +0 -25
- package/src/codegen/validators/typeCheck.test.ts +0 -904
- package/src/codegen/validators/typeCheck.ts +0 -1031
- package/src/codegen/validators/uniqueNames.test.ts +0 -59
- package/src/codegen/validators/uniqueNames.ts +0 -39
- package/src/lib/cleanupFiles.ts +0 -20
- package/src/lib/config.test.ts +0 -13
- package/src/lib/config.ts +0 -943
- package/src/lib/constants.ts +0 -11
- package/src/lib/error.ts +0 -24
- package/src/lib/fs.ts +0 -285
- package/src/lib/graphql.test.ts +0 -211
- package/src/lib/graphql.ts +0 -200
- package/src/lib/imports.ts +0 -82
- package/src/lib/index.ts +0 -17
- package/src/lib/introspection.ts +0 -39
- package/src/lib/parse.test.ts +0 -75
- package/src/lib/parse.ts +0 -23
- package/src/lib/path.ts +0 -49
- package/src/lib/pipeline.ts +0 -17
- package/src/lib/types.ts +0 -34
- package/src/lib/walk.ts +0 -104
- package/src/runtime/cache/cache.ts +0 -1023
- package/src/runtime/cache/gc.ts +0 -56
- package/src/runtime/cache/index.ts +0 -3
- package/src/runtime/cache/lists.ts +0 -502
- package/src/runtime/cache/storage.ts +0 -574
- package/src/runtime/cache/stuff.ts +0 -77
- package/src/runtime/cache/subscription.ts +0 -329
- package/src/runtime/cache/tests/availability.test.ts +0 -408
- package/src/runtime/cache/tests/gc.test.ts +0 -319
- package/src/runtime/cache/tests/keys.test.ts +0 -36
- package/src/runtime/cache/tests/list.test.ts +0 -3747
- package/src/runtime/cache/tests/readwrite.test.ts +0 -1201
- package/src/runtime/cache/tests/scalars.test.ts +0 -218
- package/src/runtime/cache/tests/storage.test.ts +0 -426
- package/src/runtime/cache/tests/subscriptions.test.ts +0 -1757
- package/src/runtime/index.ts +0 -29
- package/src/runtime/lib/config.ts +0 -201
- package/src/runtime/lib/constants.ts +0 -17
- package/src/runtime/lib/deepEquals.ts +0 -32
- package/src/runtime/lib/errors.ts +0 -8
- package/src/runtime/lib/index.ts +0 -8
- package/src/runtime/lib/log.ts +0 -69
- package/src/runtime/lib/network.ts +0 -303
- package/src/runtime/lib/networkUtils.ts +0 -151
- package/src/runtime/lib/scalars.test.ts +0 -877
- package/src/runtime/lib/scalars.ts +0 -195
- package/src/runtime/lib/types.ts +0 -194
- package/src/test/index.ts +0 -294
- package/src/vite/ast.ts +0 -107
- package/src/vite/houdini.ts +0 -113
- package/src/vite/imports.ts +0 -129
- package/src/vite/index.ts +0 -55
- package/src/vite/schema.ts +0 -80
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { test, vi, expect } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { testConfigFile } from '../../../test'
|
|
4
|
-
import { Cache } from '../cache'
|
|
5
|
-
|
|
6
|
-
const config = testConfigFile()
|
|
7
|
-
config.cacheBufferSize! = 10
|
|
8
|
-
|
|
9
|
-
test('adequate ticks of garbage collector clear unsubscribed data', function () {
|
|
10
|
-
const cache = new Cache(config)
|
|
11
|
-
|
|
12
|
-
const userFields = {
|
|
13
|
-
id: {
|
|
14
|
-
type: 'ID',
|
|
15
|
-
keyRaw: 'id',
|
|
16
|
-
},
|
|
17
|
-
firstName: {
|
|
18
|
-
type: 'String',
|
|
19
|
-
keyRaw: 'firstName',
|
|
20
|
-
},
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
cache.write({
|
|
24
|
-
selection: {
|
|
25
|
-
viewer: {
|
|
26
|
-
type: 'User',
|
|
27
|
-
keyRaw: 'viewer',
|
|
28
|
-
fields: userFields,
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
data: {
|
|
32
|
-
viewer: {
|
|
33
|
-
id: '1',
|
|
34
|
-
firstName: 'bob',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
// tick the garbage collector enough times to fill up the buffer size
|
|
40
|
-
for (const _ of Array.from({ length: config.cacheBufferSize! })) {
|
|
41
|
-
cache._internal_unstable.collectGarbage()
|
|
42
|
-
expect(cache.read({ selection: userFields, parent: 'User:1' })).toMatchObject({
|
|
43
|
-
data: { id: '1' },
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// collecting garbage one more time should delete the record from the cache
|
|
48
|
-
cache._internal_unstable.collectGarbage()
|
|
49
|
-
expect(cache.read({ selection: userFields, parent: 'User:1' })).toMatchObject({
|
|
50
|
-
data: null,
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test("subscribed data shouldn't be garbage collected", function () {
|
|
55
|
-
const cache = new Cache(testConfigFile())
|
|
56
|
-
|
|
57
|
-
cache.write({
|
|
58
|
-
selection: {
|
|
59
|
-
viewer: {
|
|
60
|
-
type: 'User',
|
|
61
|
-
keyRaw: 'viewer',
|
|
62
|
-
fields: {
|
|
63
|
-
id: {
|
|
64
|
-
type: 'ID',
|
|
65
|
-
keyRaw: 'id',
|
|
66
|
-
},
|
|
67
|
-
firstName: {
|
|
68
|
-
type: 'String',
|
|
69
|
-
keyRaw: 'firstName',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
data: {
|
|
75
|
-
viewer: {
|
|
76
|
-
id: '1',
|
|
77
|
-
firstName: 'bob',
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
// subscribe to the fields
|
|
83
|
-
cache.subscribe({
|
|
84
|
-
rootType: 'Query',
|
|
85
|
-
selection: {
|
|
86
|
-
viewer: {
|
|
87
|
-
type: 'User',
|
|
88
|
-
keyRaw: 'viewer',
|
|
89
|
-
fields: {
|
|
90
|
-
id: {
|
|
91
|
-
type: 'ID',
|
|
92
|
-
keyRaw: 'id',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
set: vi.fn(),
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
// tick the garbage collector enough times to fill up the buffer size
|
|
101
|
-
for (const _ of Array.from({ length: config.cacheBufferSize! + 1 })) {
|
|
102
|
-
cache._internal_unstable.collectGarbage()
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
expect(
|
|
106
|
-
cache.read({
|
|
107
|
-
selection: {
|
|
108
|
-
id: {
|
|
109
|
-
type: 'ID',
|
|
110
|
-
keyRaw: 'id',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
parent: 'User:1',
|
|
114
|
-
}).data
|
|
115
|
-
).toEqual({ id: '1' })
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
test('resubscribing to fields marked for garbage collection resets counter', function () {
|
|
119
|
-
const cache = new Cache(testConfigFile())
|
|
120
|
-
|
|
121
|
-
cache.write({
|
|
122
|
-
selection: {
|
|
123
|
-
viewer: {
|
|
124
|
-
type: 'User',
|
|
125
|
-
keyRaw: 'viewer',
|
|
126
|
-
fields: {
|
|
127
|
-
id: {
|
|
128
|
-
type: 'ID',
|
|
129
|
-
keyRaw: 'id',
|
|
130
|
-
},
|
|
131
|
-
firstName: {
|
|
132
|
-
type: 'String',
|
|
133
|
-
keyRaw: 'firstName',
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
data: {
|
|
139
|
-
viewer: {
|
|
140
|
-
id: '1',
|
|
141
|
-
firstName: 'bob',
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
// tick the gc 3 times
|
|
147
|
-
for (const _ of Array.from({ length: 3 })) {
|
|
148
|
-
cache._internal_unstable.collectGarbage()
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const set = vi.fn()
|
|
152
|
-
|
|
153
|
-
// subscribe to the fields
|
|
154
|
-
cache.subscribe({
|
|
155
|
-
rootType: 'Query',
|
|
156
|
-
selection: {
|
|
157
|
-
viewer: {
|
|
158
|
-
type: 'User',
|
|
159
|
-
keyRaw: 'viewer',
|
|
160
|
-
fields: {
|
|
161
|
-
id: {
|
|
162
|
-
type: 'ID',
|
|
163
|
-
keyRaw: 'id',
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
set,
|
|
169
|
-
})
|
|
170
|
-
|
|
171
|
-
// tick the garbage collector enough times to fill up the buffer size
|
|
172
|
-
for (const _ of Array.from({ length: config.cacheBufferSize! })) {
|
|
173
|
-
cache._internal_unstable.collectGarbage()
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// subscribe to the fields
|
|
177
|
-
cache.unsubscribe({
|
|
178
|
-
rootType: 'Query',
|
|
179
|
-
selection: {
|
|
180
|
-
viewer: {
|
|
181
|
-
type: 'User',
|
|
182
|
-
keyRaw: 'viewer',
|
|
183
|
-
fields: {
|
|
184
|
-
id: {
|
|
185
|
-
type: 'ID',
|
|
186
|
-
keyRaw: 'id',
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
set,
|
|
192
|
-
})
|
|
193
|
-
|
|
194
|
-
// tick the garbage collector enough times to fill up the buffer size
|
|
195
|
-
for (const _ of Array.from({ length: config.cacheBufferSize! })) {
|
|
196
|
-
cache._internal_unstable.collectGarbage()
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// make sure we still have a value
|
|
200
|
-
expect(
|
|
201
|
-
cache.read({
|
|
202
|
-
selection: {
|
|
203
|
-
id: {
|
|
204
|
-
type: 'ID',
|
|
205
|
-
keyRaw: 'id',
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
parent: 'User:1',
|
|
209
|
-
}).data
|
|
210
|
-
).toEqual({ id: '1' })
|
|
211
|
-
|
|
212
|
-
// tick once more to clear the garbage
|
|
213
|
-
cache._internal_unstable.collectGarbage()
|
|
214
|
-
|
|
215
|
-
expect(
|
|
216
|
-
cache.read({
|
|
217
|
-
selection: {
|
|
218
|
-
id: {
|
|
219
|
-
type: 'ID',
|
|
220
|
-
keyRaw: 'id',
|
|
221
|
-
},
|
|
222
|
-
},
|
|
223
|
-
parent: 'User:1',
|
|
224
|
-
})
|
|
225
|
-
).toMatchObject({
|
|
226
|
-
data: null,
|
|
227
|
-
})
|
|
228
|
-
})
|
|
229
|
-
|
|
230
|
-
test('ticks of gc delete list handlers', function () {
|
|
231
|
-
// instantiate a cache
|
|
232
|
-
const cache = new Cache(config)
|
|
233
|
-
|
|
234
|
-
const selection = {
|
|
235
|
-
viewer: {
|
|
236
|
-
type: 'User',
|
|
237
|
-
keyRaw: 'viewer',
|
|
238
|
-
fields: {
|
|
239
|
-
id: {
|
|
240
|
-
type: 'ID',
|
|
241
|
-
keyRaw: 'id',
|
|
242
|
-
},
|
|
243
|
-
friends: {
|
|
244
|
-
type: 'User',
|
|
245
|
-
// the key takes an argument so that we can have multiple
|
|
246
|
-
// lists tracked in the cache
|
|
247
|
-
keyRaw: 'friends',
|
|
248
|
-
list: {
|
|
249
|
-
name: 'All_Users',
|
|
250
|
-
connection: false,
|
|
251
|
-
type: 'User',
|
|
252
|
-
},
|
|
253
|
-
fields: {
|
|
254
|
-
id: {
|
|
255
|
-
type: 'ID',
|
|
256
|
-
keyRaw: 'id',
|
|
257
|
-
},
|
|
258
|
-
firstName: {
|
|
259
|
-
type: 'String',
|
|
260
|
-
keyRaw: 'firstName',
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
// start off associated with one object
|
|
269
|
-
cache.write({
|
|
270
|
-
selection,
|
|
271
|
-
variables: {
|
|
272
|
-
var: 'hello',
|
|
273
|
-
},
|
|
274
|
-
data: {
|
|
275
|
-
viewer: {
|
|
276
|
-
id: '1',
|
|
277
|
-
friends: [
|
|
278
|
-
{
|
|
279
|
-
id: '2',
|
|
280
|
-
firstName: 'yves',
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
})
|
|
286
|
-
|
|
287
|
-
// a function to spy on that will play the role of set
|
|
288
|
-
const set = vi.fn()
|
|
289
|
-
|
|
290
|
-
cache.subscribe(
|
|
291
|
-
{
|
|
292
|
-
rootType: 'Query',
|
|
293
|
-
set,
|
|
294
|
-
selection,
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
var: 'hello',
|
|
298
|
-
}
|
|
299
|
-
)
|
|
300
|
-
|
|
301
|
-
cache.unsubscribe(
|
|
302
|
-
{
|
|
303
|
-
rootType: 'Query',
|
|
304
|
-
set,
|
|
305
|
-
selection,
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
var: 'hello',
|
|
309
|
-
}
|
|
310
|
-
)
|
|
311
|
-
|
|
312
|
-
// tick the garbage collector enough times to trigger garbage collection
|
|
313
|
-
for (const _ of Array.from({ length: config.cacheBufferSize! + 1 })) {
|
|
314
|
-
cache._internal_unstable.collectGarbage()
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// make sure we dont have a handler for the list
|
|
318
|
-
expect(cache._internal_unstable.lists.get('All_Users')).toBeNull()
|
|
319
|
-
})
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { evaluateKey } from '../stuff'
|
|
4
|
-
|
|
5
|
-
describe('key evaluation', function () {
|
|
6
|
-
const table = [
|
|
7
|
-
{
|
|
8
|
-
title: 'string',
|
|
9
|
-
key: 'fieldName',
|
|
10
|
-
expected: 'fieldName',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
title: 'variable',
|
|
14
|
-
key: 'fieldName(foo: $bar)',
|
|
15
|
-
variables: { bar: 'baz' },
|
|
16
|
-
expected: 'fieldName(foo: "baz")',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
title: '$ in string',
|
|
20
|
-
key: 'fieldName(foo: "$bar")',
|
|
21
|
-
variables: { bar: 'baz' },
|
|
22
|
-
expected: 'fieldName(foo: "$bar")',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
title: 'undefined variable',
|
|
26
|
-
key: 'fieldName(foo: $bar)',
|
|
27
|
-
expected: 'fieldName(foo: undefined)',
|
|
28
|
-
},
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
for (const row of table) {
|
|
32
|
-
test(row.title, function () {
|
|
33
|
-
expect(evaluateKey(row.key, row.variables)).toEqual(row.expected)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
})
|