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