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