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.
Files changed (121) hide show
  1. package/README.md +33 -0
  2. package/build/cmd-cjs/index.js +2 -2
  3. package/build/cmd-esm/index.js +2 -2
  4. package/package.json +16 -1
  5. package/.turbo/turbo-compile.log +0 -5
  6. package/.turbo/turbo-typedefs.log +0 -5
  7. package/CHANGELOG.md +0 -377
  8. package/src/cmd/generate.ts +0 -54
  9. package/src/cmd/index.ts +0 -60
  10. package/src/cmd/init.ts +0 -637
  11. package/src/cmd/pullSchema.ts +0 -40
  12. package/src/codegen/generators/artifacts/artifacts.test.ts +0 -3246
  13. package/src/codegen/generators/artifacts/fieldKey.ts +0 -60
  14. package/src/codegen/generators/artifacts/index.ts +0 -330
  15. package/src/codegen/generators/artifacts/indexFile.ts +0 -24
  16. package/src/codegen/generators/artifacts/inputs.ts +0 -81
  17. package/src/codegen/generators/artifacts/operations.ts +0 -281
  18. package/src/codegen/generators/artifacts/pagination.test.ts +0 -664
  19. package/src/codegen/generators/artifacts/policy.test.ts +0 -298
  20. package/src/codegen/generators/artifacts/selection.ts +0 -208
  21. package/src/codegen/generators/artifacts/utils.test.ts +0 -118
  22. package/src/codegen/generators/artifacts/utils.ts +0 -108
  23. package/src/codegen/generators/definitions/enums.test.ts +0 -61
  24. package/src/codegen/generators/definitions/enums.ts +0 -68
  25. package/src/codegen/generators/definitions/index.ts +0 -11
  26. package/src/codegen/generators/definitions/schema.test.ts +0 -236
  27. package/src/codegen/generators/index.ts +0 -6
  28. package/src/codegen/generators/indexFile/index.ts +0 -63
  29. package/src/codegen/generators/indexFile/indexFile.test.ts +0 -72
  30. package/src/codegen/generators/persistedQueries/index.ts +0 -55
  31. package/src/codegen/generators/persistedQueries/persistedQuery.test.ts +0 -26
  32. package/src/codegen/generators/runtime/index.test.ts +0 -74
  33. package/src/codegen/generators/runtime/index.ts +0 -64
  34. package/src/codegen/generators/runtime/runtime.test.ts +0 -25
  35. package/src/codegen/generators/typescript/addReferencedInputTypes.ts +0 -77
  36. package/src/codegen/generators/typescript/index.ts +0 -412
  37. package/src/codegen/generators/typescript/inlineType.ts +0 -409
  38. package/src/codegen/generators/typescript/typeReference.ts +0 -44
  39. package/src/codegen/generators/typescript/types.ts +0 -81
  40. package/src/codegen/generators/typescript/typescript.test.ts +0 -1434
  41. package/src/codegen/index.ts +0 -406
  42. package/src/codegen/transforms/addID.test.ts +0 -93
  43. package/src/codegen/transforms/addID.ts +0 -86
  44. package/src/codegen/transforms/composeQueries.test.ts +0 -50
  45. package/src/codegen/transforms/composeQueries.ts +0 -154
  46. package/src/codegen/transforms/fragmentVariables.test.ts +0 -636
  47. package/src/codegen/transforms/fragmentVariables.ts +0 -417
  48. package/src/codegen/transforms/index.ts +0 -7
  49. package/src/codegen/transforms/list.ts +0 -484
  50. package/src/codegen/transforms/lists.test.ts +0 -530
  51. package/src/codegen/transforms/paginate.test.ts +0 -1528
  52. package/src/codegen/transforms/paginate.ts +0 -770
  53. package/src/codegen/transforms/schema.test.ts +0 -136
  54. package/src/codegen/transforms/schema.ts +0 -109
  55. package/src/codegen/transforms/typename.test.ts +0 -125
  56. package/src/codegen/transforms/typename.ts +0 -55
  57. package/src/codegen/utils/commonjs.ts +0 -26
  58. package/src/codegen/utils/flattenSelections.ts +0 -179
  59. package/src/codegen/utils/graphql.test.ts +0 -35
  60. package/src/codegen/utils/graphql.ts +0 -79
  61. package/src/codegen/utils/index.ts +0 -5
  62. package/src/codegen/utils/moduleExport.ts +0 -27
  63. package/src/codegen/utils/murmur.ts +0 -79
  64. package/src/codegen/validators/index.ts +0 -4
  65. package/src/codegen/validators/noIDAlias.test.ts +0 -71
  66. package/src/codegen/validators/noIDAlias.ts +0 -39
  67. package/src/codegen/validators/plugins.ts +0 -25
  68. package/src/codegen/validators/typeCheck.test.ts +0 -960
  69. package/src/codegen/validators/typeCheck.ts +0 -1086
  70. package/src/codegen/validators/uniqueNames.test.ts +0 -59
  71. package/src/codegen/validators/uniqueNames.ts +0 -39
  72. package/src/lib/cleanupFiles.ts +0 -20
  73. package/src/lib/config.test.ts +0 -13
  74. package/src/lib/config.ts +0 -954
  75. package/src/lib/constants.ts +0 -11
  76. package/src/lib/error.ts +0 -24
  77. package/src/lib/fs.ts +0 -285
  78. package/src/lib/graphql.test.ts +0 -211
  79. package/src/lib/graphql.ts +0 -200
  80. package/src/lib/imports.ts +0 -82
  81. package/src/lib/index.ts +0 -17
  82. package/src/lib/introspection.ts +0 -39
  83. package/src/lib/parse.test.ts +0 -75
  84. package/src/lib/parse.ts +0 -23
  85. package/src/lib/path.ts +0 -49
  86. package/src/lib/pipeline.ts +0 -17
  87. package/src/lib/types.ts +0 -34
  88. package/src/lib/walk.ts +0 -104
  89. package/src/runtime/cache/cache.ts +0 -1026
  90. package/src/runtime/cache/gc.ts +0 -56
  91. package/src/runtime/cache/index.ts +0 -3
  92. package/src/runtime/cache/lists.ts +0 -516
  93. package/src/runtime/cache/storage.ts +0 -574
  94. package/src/runtime/cache/stuff.ts +0 -77
  95. package/src/runtime/cache/subscription.ts +0 -329
  96. package/src/runtime/cache/tests/availability.test.ts +0 -408
  97. package/src/runtime/cache/tests/gc.test.ts +0 -319
  98. package/src/runtime/cache/tests/keys.test.ts +0 -36
  99. package/src/runtime/cache/tests/list.test.ts +0 -3854
  100. package/src/runtime/cache/tests/readwrite.test.ts +0 -1201
  101. package/src/runtime/cache/tests/scalars.test.ts +0 -218
  102. package/src/runtime/cache/tests/storage.test.ts +0 -426
  103. package/src/runtime/cache/tests/subscriptions.test.ts +0 -1757
  104. package/src/runtime/index.ts +0 -29
  105. package/src/runtime/lib/config.ts +0 -211
  106. package/src/runtime/lib/constants.ts +0 -17
  107. package/src/runtime/lib/deepEquals.ts +0 -32
  108. package/src/runtime/lib/errors.ts +0 -8
  109. package/src/runtime/lib/index.ts +0 -8
  110. package/src/runtime/lib/log.ts +0 -69
  111. package/src/runtime/lib/network.ts +0 -303
  112. package/src/runtime/lib/networkUtils.ts +0 -151
  113. package/src/runtime/lib/scalars.test.ts +0 -877
  114. package/src/runtime/lib/scalars.ts +0 -195
  115. package/src/runtime/lib/types.ts +0 -195
  116. package/src/test/index.ts +0 -294
  117. package/src/vite/ast.ts +0 -107
  118. package/src/vite/houdini.ts +0 -113
  119. package/src/vite/imports.ts +0 -129
  120. package/src/vite/index.ts +0 -55
  121. package/src/vite/schema.ts +0 -80
@@ -1,1528 +0,0 @@
1
- import { test, expect } from 'vitest'
2
-
3
- import { runPipeline } from '../../codegen'
4
- import { mockCollectedDoc, testConfig } from '../../test'
5
-
6
- test('adds pagination info to full', async function () {
7
- const docs = [
8
- mockCollectedDoc(
9
- `
10
- fragment UserFriends on Query {
11
- usersByCursor(first: 10) @paginate {
12
- edges {
13
- node {
14
- id
15
- }
16
- }
17
- }
18
- }
19
- `
20
- ),
21
- ]
22
-
23
- // run the pipeline
24
- const config = testConfig()
25
- await runPipeline(config, docs)
26
-
27
- // load the contents of the file
28
- expect(docs[0].document).toMatchInlineSnapshot(`
29
- fragment UserFriends on Query @arguments(first: {type: "Int", default: 10}, after: {type: "String"}) {
30
- usersByCursor(first: $first, after: $after) @paginate {
31
- edges {
32
- node {
33
- id
34
- }
35
- }
36
- edges {
37
- cursor
38
- node {
39
- __typename
40
- }
41
- }
42
- pageInfo {
43
- hasPreviousPage
44
- hasNextPage
45
- startCursor
46
- endCursor
47
- }
48
- }
49
- }
50
-
51
- `)
52
-
53
- expect(docs[0].refetch).toMatchInlineSnapshot(`
54
- {
55
- "update": "append",
56
- "path": [
57
- "usersByCursor"
58
- ],
59
- "method": "cursor",
60
- "pageSize": 10,
61
- "embedded": false,
62
- "targetType": "Query",
63
- "paginated": true,
64
- "direction": "forward"
65
- }
66
- `)
67
- })
68
-
69
- test('paginated fragments on node pull data from one field deeper', async function () {
70
- const docs = [
71
- mockCollectedDoc(
72
- `
73
- fragment UserFriends on User {
74
- friendsByCursor(first: 10) @paginate {
75
- edges {
76
- node {
77
- id
78
- }
79
- }
80
- }
81
- }
82
- `
83
- ),
84
- ]
85
-
86
- // run the pipeline
87
- const config = testConfig()
88
- await runPipeline(config, docs)
89
-
90
- expect(docs[0].refetch).toMatchInlineSnapshot(`
91
- {
92
- "update": "append",
93
- "path": [
94
- "friendsByCursor"
95
- ],
96
- "method": "cursor",
97
- "pageSize": 10,
98
- "embedded": true,
99
- "targetType": "Node",
100
- "paginated": true,
101
- "direction": "forward"
102
- }
103
- `)
104
- })
105
-
106
- test("doesn't add pagination info to offset pagination", async function () {
107
- const docs = [
108
- mockCollectedDoc(
109
- `
110
- fragment UserFriends on Query {
111
- usersByOffset(limit: 10) @paginate {
112
- id
113
- }
114
- }
115
- `
116
- ),
117
- ]
118
-
119
- // run the pipeline
120
- const config = testConfig()
121
- await runPipeline(config, docs)
122
-
123
- // load the contents of the file
124
- expect(docs[0].document).toMatchInlineSnapshot(`
125
- fragment UserFriends on Query @arguments(limit: {type: "Int", default: 10}, offset: {type: "Int"}) {
126
- usersByOffset(limit: $limit, offset: $offset) @paginate {
127
- id
128
- }
129
- }
130
-
131
- `)
132
- })
133
-
134
- test('paginate adds forwards cursor args to the full cursor fragment', async function () {
135
- const docs = [
136
- mockCollectedDoc(
137
- `
138
- fragment UserFriends on Query {
139
- usersByCursor(first: 10) @paginate {
140
- edges {
141
- node {
142
- id
143
- }
144
- }
145
- }
146
- }
147
- `
148
- ),
149
- ]
150
-
151
- // run the pipeline
152
- const config = testConfig()
153
- await runPipeline(config, docs)
154
-
155
- // load the contents of the file
156
- expect(docs[0].document).toMatchInlineSnapshot(`
157
- fragment UserFriends on Query @arguments(first: {type: "Int", default: 10}, after: {type: "String"}) {
158
- usersByCursor(first: $first, after: $after) @paginate {
159
- edges {
160
- node {
161
- id
162
- }
163
- }
164
- edges {
165
- cursor
166
- node {
167
- __typename
168
- }
169
- }
170
- pageInfo {
171
- hasPreviousPage
172
- hasNextPage
173
- startCursor
174
- endCursor
175
- }
176
- }
177
- }
178
-
179
- `)
180
- })
181
-
182
- test('paginate adds backwards cursor args to the full cursor fragment', async function () {
183
- const docs = [
184
- mockCollectedDoc(
185
- `
186
- fragment UserFriends on Query {
187
- usersByCursor(last: 10) @paginate {
188
- edges {
189
- node {
190
- id
191
- }
192
- }
193
- }
194
- }
195
- `
196
- ),
197
- ]
198
-
199
- // run the pipeline
200
- const config = testConfig()
201
- await runPipeline(config, docs)
202
-
203
- // load the contents of the file
204
- expect(docs[0].document).toMatchInlineSnapshot(`
205
- fragment UserFriends on Query @arguments(last: {type: "Int", default: 10}, before: {type: "String"}) {
206
- usersByCursor(last: $last, before: $before) @paginate {
207
- edges {
208
- node {
209
- id
210
- }
211
- }
212
- edges {
213
- cursor
214
- node {
215
- __typename
216
- }
217
- }
218
- pageInfo {
219
- hasPreviousPage
220
- hasNextPage
221
- startCursor
222
- endCursor
223
- }
224
- }
225
- }
226
-
227
- `)
228
- })
229
-
230
- test('paginate adds forwards cursor args to the fragment', async function () {
231
- const docs = [
232
- mockCollectedDoc(
233
- `
234
- fragment UserFriends on Query {
235
- usersByForwardsCursor(first: 10) @paginate {
236
- edges {
237
- node {
238
- id
239
- }
240
- }
241
- }
242
- }
243
- `
244
- ),
245
- ]
246
-
247
- // run the pipeline
248
- const config = testConfig()
249
- await runPipeline(config, docs)
250
-
251
- // load the contents of the file
252
- expect(docs[0].document).toMatchInlineSnapshot(`
253
- fragment UserFriends on Query @arguments(first: {type: "Int", default: 10}, after: {type: "String"}) {
254
- usersByForwardsCursor(first: $first, after: $after) @paginate {
255
- edges {
256
- node {
257
- id
258
- }
259
- }
260
- edges {
261
- cursor
262
- node {
263
- __typename
264
- }
265
- }
266
- pageInfo {
267
- hasPreviousPage
268
- hasNextPage
269
- startCursor
270
- endCursor
271
- }
272
- }
273
- }
274
-
275
- `)
276
- })
277
-
278
- test('paginate adds backwards cursor args to the fragment', async function () {
279
- const docs = [
280
- mockCollectedDoc(
281
- `
282
- fragment UserFriends on Query {
283
- usersByBackwardsCursor(last: 10) @paginate {
284
- edges {
285
- node {
286
- id
287
- }
288
- }
289
- }
290
- }
291
- `
292
- ),
293
- ]
294
-
295
- // run the pipeline
296
- const config = testConfig()
297
- await runPipeline(config, docs)
298
-
299
- // load the contents of the file
300
- expect(docs[0].document).toMatchInlineSnapshot(`
301
- fragment UserFriends on Query @arguments(last: {type: "Int", default: 10}, before: {type: "String"}) {
302
- usersByBackwardsCursor(last: $last, before: $before) @paginate {
303
- edges {
304
- node {
305
- id
306
- }
307
- }
308
- edges {
309
- cursor
310
- node {
311
- __typename
312
- }
313
- }
314
- pageInfo {
315
- hasPreviousPage
316
- hasNextPage
317
- startCursor
318
- endCursor
319
- }
320
- }
321
- }
322
-
323
- `)
324
- })
325
-
326
- test('sets before with default value', async function () {
327
- const docs = [
328
- mockCollectedDoc(
329
- `
330
- fragment UserFriends on Query {
331
- usersByCursor(last: 10, before: "cursor") @paginate {
332
- edges {
333
- node {
334
- id
335
- }
336
- }
337
- }
338
- }
339
- `
340
- ),
341
- // mockCollectedDoc('')
342
- ]
343
-
344
- // run the pipeline
345
- const config = testConfig()
346
- await runPipeline(config, docs)
347
-
348
- // load the contents of the file
349
- expect(docs[0].document).toMatchInlineSnapshot(`
350
- fragment UserFriends on Query @arguments(last: {type: "Int", default: 10}, before: {type: "String", default: "cursor"}) {
351
- usersByCursor(last: $last, before: $before) @paginate {
352
- edges {
353
- node {
354
- id
355
- }
356
- }
357
- edges {
358
- cursor
359
- node {
360
- __typename
361
- }
362
- }
363
- pageInfo {
364
- hasPreviousPage
365
- hasNextPage
366
- startCursor
367
- endCursor
368
- }
369
- }
370
- }
371
-
372
- `)
373
- })
374
-
375
- test('embeds pagination query as a separate document', async function () {
376
- const docs = [
377
- mockCollectedDoc(
378
- `
379
- fragment UserFriends on Query {
380
- usersByForwardsCursor(first: 10) @paginate {
381
- edges {
382
- node {
383
- id
384
- }
385
- }
386
- }
387
- }
388
- `
389
- ),
390
- ]
391
-
392
- // run the pipeline
393
- const config = testConfig()
394
- await runPipeline(config, docs)
395
-
396
- // load the contents of the file
397
- expect(docs[1]?.document).toMatchInlineSnapshot(`
398
- query UserFriends_Pagination_Query($first: Int = 10, $after: String) {
399
- ...UserFriends_jrGTj @with(first: $first, after: $after)
400
- }
401
-
402
- fragment UserFriends_jrGTj on Query @arguments(first: {type: "Int", default: 10}, after: {type: "String"}) {
403
- usersByForwardsCursor(first: $first, after: $after) @paginate {
404
- edges {
405
- node {
406
- id
407
- }
408
- }
409
- edges {
410
- cursor
411
- node {
412
- __typename
413
- }
414
- }
415
- pageInfo {
416
- hasPreviousPage
417
- hasNextPage
418
- startCursor
419
- endCursor
420
- }
421
- }
422
- }
423
-
424
- `)
425
- })
426
-
427
- test('embeds node pagination query as a separate document', async function () {
428
- const docs = [
429
- mockCollectedDoc(
430
- `
431
- fragment UserFriends on User {
432
- friendsByForwardsCursor(first: 10) @paginate {
433
- edges {
434
- node {
435
- id
436
- }
437
- }
438
- }
439
- }
440
- `
441
- ),
442
- ]
443
-
444
- // run the pipeline
445
- const config = testConfig()
446
- await runPipeline(config, docs)
447
-
448
- // load the contents of the file
449
- await expect(docs[1]).toMatchInlineSnapshot(`
450
- export default {
451
- name: "UserFriends_Pagination_Query",
452
- kind: "HoudiniQuery",
453
- hash: "bb5131f921805b85c17e7b882f4ad66a9dad452d0f66534a1c8b8f9942adec48",
454
-
455
- refetch: {
456
- update: "append",
457
- path: ["friendsByForwardsCursor"],
458
- method: "cursor",
459
- pageSize: 10,
460
- embedded: true,
461
- targetType: "Node",
462
- paginated: true,
463
- direction: "forward"
464
- },
465
-
466
- raw: \`query UserFriends_Pagination_Query($first: Int = 10, $after: String, $id: ID!) {
467
- node(id: $id) {
468
- __typename
469
- id
470
- ...UserFriends_jrGTj
471
- }
472
- }
473
-
474
- fragment UserFriends_jrGTj on User {
475
- friendsByForwardsCursor(first: $first, after: $after) {
476
- edges {
477
- node {
478
- id
479
- }
480
- }
481
- edges {
482
- cursor
483
- node {
484
- __typename
485
- }
486
- }
487
- pageInfo {
488
- hasPreviousPage
489
- hasNextPage
490
- startCursor
491
- endCursor
492
- }
493
- }
494
- }
495
- \`,
496
-
497
- rootType: "Query",
498
-
499
- selection: {
500
- node: {
501
- type: "Node",
502
- keyRaw: "node(id: $id)",
503
- nullable: true,
504
-
505
- fields: {
506
- __typename: {
507
- type: "String",
508
- keyRaw: "__typename"
509
- },
510
-
511
- id: {
512
- type: "ID",
513
- keyRaw: "id"
514
- },
515
-
516
- friendsByForwardsCursor: {
517
- type: "UserConnection",
518
- keyRaw: "friendsByForwardsCursor::paginated",
519
-
520
- fields: {
521
- edges: {
522
- type: "UserEdge",
523
- keyRaw: "edges",
524
-
525
- fields: {
526
- cursor: {
527
- type: "String",
528
- keyRaw: "cursor"
529
- },
530
-
531
- node: {
532
- type: "User",
533
- keyRaw: "node",
534
- nullable: true,
535
-
536
- fields: {
537
- __typename: {
538
- type: "String",
539
- keyRaw: "__typename"
540
- },
541
-
542
- id: {
543
- type: "ID",
544
- keyRaw: "id"
545
- }
546
- }
547
- }
548
- },
549
-
550
- update: "append"
551
- },
552
-
553
- pageInfo: {
554
- type: "PageInfo",
555
- keyRaw: "pageInfo",
556
-
557
- fields: {
558
- hasPreviousPage: {
559
- type: "Boolean",
560
- keyRaw: "hasPreviousPage"
561
- },
562
-
563
- hasNextPage: {
564
- type: "Boolean",
565
- keyRaw: "hasNextPage"
566
- },
567
-
568
- startCursor: {
569
- type: "String",
570
- keyRaw: "startCursor"
571
- },
572
-
573
- endCursor: {
574
- type: "String",
575
- keyRaw: "endCursor"
576
- }
577
- }
578
- }
579
- }
580
- }
581
- },
582
-
583
- abstract: true
584
- }
585
- },
586
-
587
- input: {
588
- fields: {
589
- first: "Int",
590
- after: "String",
591
- id: "ID"
592
- },
593
-
594
- types: {}
595
- },
596
-
597
- policy: "CacheOrNetwork",
598
- partial: false
599
- };
600
-
601
- "HoudiniHash=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
602
- `)
603
- })
604
-
605
- test('embeds custom pagination query as a separate document', async function () {
606
- const docs = [
607
- mockCollectedDoc(
608
- `
609
- fragment UserGhost on Ghost {
610
- friendsConnection(first: 10) @paginate {
611
- edges {
612
- node {
613
- name
614
- }
615
- }
616
- }
617
- }
618
- `
619
- ),
620
- ]
621
-
622
- // run the pipeline
623
- const config = testConfig({
624
- types: {
625
- Ghost: {
626
- keys: ['name', 'aka'],
627
- resolve: {
628
- queryField: 'ghost',
629
- arguments: (ghost) => ({
630
- name: ghost.name,
631
- aka: ghost.aka,
632
- }),
633
- },
634
- },
635
- },
636
- })
637
- await runPipeline(config, docs)
638
-
639
- // load the contents of the file
640
- await expect(docs[1]).toMatchInlineSnapshot(`
641
- export default {
642
- name: "UserGhost_Pagination_Query",
643
- kind: "HoudiniQuery",
644
- hash: "55c27b299d485bf73adfaa418b77ac03d918e2ce579730d328208318c6af0da5",
645
-
646
- refetch: {
647
- update: "append",
648
- path: ["friendsConnection"],
649
- method: "cursor",
650
- pageSize: 10,
651
- embedded: true,
652
- targetType: "Ghost",
653
- paginated: true,
654
- direction: "forward"
655
- },
656
-
657
- raw: \`query UserGhost_Pagination_Query($first: Int = 10, $after: String, $name: String!, $aka: String!) {
658
- ghost(name: $name, aka: $aka) {
659
- __typename
660
- name
661
- aka
662
- ...UserGhost_jrGTj
663
- }
664
- }
665
-
666
- fragment UserGhost_jrGTj on Ghost {
667
- friendsConnection(first: $first, after: $after) {
668
- edges {
669
- node {
670
- name
671
- aka
672
- }
673
- }
674
- edges {
675
- cursor
676
- node {
677
- __typename
678
- }
679
- }
680
- pageInfo {
681
- hasPreviousPage
682
- hasNextPage
683
- startCursor
684
- endCursor
685
- }
686
- }
687
- }
688
- \`,
689
-
690
- rootType: "Query",
691
-
692
- selection: {
693
- ghost: {
694
- type: "Ghost",
695
- keyRaw: "ghost(name: $name, aka: $aka)",
696
-
697
- fields: {
698
- __typename: {
699
- type: "String",
700
- keyRaw: "__typename"
701
- },
702
-
703
- name: {
704
- type: "String",
705
- keyRaw: "name"
706
- },
707
-
708
- aka: {
709
- type: "String",
710
- keyRaw: "aka"
711
- },
712
-
713
- friendsConnection: {
714
- type: "GhostConnection",
715
- keyRaw: "friendsConnection::paginated",
716
-
717
- fields: {
718
- edges: {
719
- type: "GhostEdge",
720
- keyRaw: "edges",
721
-
722
- fields: {
723
- cursor: {
724
- type: "String",
725
- keyRaw: "cursor"
726
- },
727
-
728
- node: {
729
- type: "Ghost",
730
- keyRaw: "node",
731
- nullable: true,
732
-
733
- fields: {
734
- __typename: {
735
- type: "String",
736
- keyRaw: "__typename"
737
- },
738
-
739
- name: {
740
- type: "String",
741
- keyRaw: "name"
742
- },
743
-
744
- aka: {
745
- type: "String",
746
- keyRaw: "aka"
747
- }
748
- }
749
- }
750
- },
751
-
752
- update: "append"
753
- },
754
-
755
- pageInfo: {
756
- type: "PageInfo",
757
- keyRaw: "pageInfo",
758
-
759
- fields: {
760
- hasPreviousPage: {
761
- type: "Boolean",
762
- keyRaw: "hasPreviousPage"
763
- },
764
-
765
- hasNextPage: {
766
- type: "Boolean",
767
- keyRaw: "hasNextPage"
768
- },
769
-
770
- startCursor: {
771
- type: "String",
772
- keyRaw: "startCursor"
773
- },
774
-
775
- endCursor: {
776
- type: "String",
777
- keyRaw: "endCursor"
778
- }
779
- }
780
- }
781
- }
782
- }
783
- }
784
- }
785
- },
786
-
787
- input: {
788
- fields: {
789
- first: "Int",
790
- after: "String",
791
- name: "String",
792
- aka: "String"
793
- },
794
-
795
- types: {}
796
- },
797
-
798
- policy: "CacheOrNetwork",
799
- partial: false
800
- };
801
-
802
- "HoudiniHash=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
803
- `)
804
- })
805
-
806
- test('query with forwards cursor paginate', async function () {
807
- const docs = [
808
- mockCollectedDoc(
809
- `
810
- query Users {
811
- usersByForwardsCursor(first: 10) @paginate {
812
- edges {
813
- node {
814
- id
815
- }
816
- }
817
- }
818
- }
819
- `
820
- ),
821
- ]
822
-
823
- // run the pipeline
824
- const config = testConfig()
825
- await runPipeline(config, docs)
826
-
827
- // load the contents of the file
828
- expect(docs[0]?.document).toMatchInlineSnapshot(`
829
- query Users($first: Int = 10, $after: String) {
830
- usersByForwardsCursor(first: $first, after: $after) @paginate {
831
- edges {
832
- node {
833
- id
834
- }
835
- }
836
- edges {
837
- cursor
838
- node {
839
- __typename
840
- }
841
- }
842
- pageInfo {
843
- hasPreviousPage
844
- hasNextPage
845
- startCursor
846
- endCursor
847
- }
848
- }
849
- }
850
-
851
- `)
852
- })
853
-
854
- test('query with custom first args', async function () {
855
- const docs = [
856
- mockCollectedDoc(
857
- `
858
- query Users ($limit: Int!){
859
- usersByForwardsCursor(first: $limit) @paginate {
860
- edges {
861
- node {
862
- id
863
- }
864
- }
865
- }
866
- }
867
- `
868
- ),
869
- ]
870
-
871
- // run the pipeline
872
- const config = testConfig()
873
- await runPipeline(config, docs)
874
-
875
- // load the contents of the file
876
- expect(docs[0]?.document).toMatchInlineSnapshot(`
877
- query Users($limit: Int!, $after: String) {
878
- usersByForwardsCursor(first: $limit, after: $after) @paginate {
879
- edges {
880
- node {
881
- id
882
- }
883
- }
884
- edges {
885
- cursor
886
- node {
887
- __typename
888
- }
889
- }
890
- pageInfo {
891
- hasPreviousPage
892
- hasNextPage
893
- startCursor
894
- endCursor
895
- }
896
- }
897
- }
898
- `)
899
- })
900
-
901
- test('query with backwards cursor paginate', async function () {
902
- const docs = [
903
- mockCollectedDoc(
904
- `
905
- query Users {
906
- usersByBackwardsCursor(last: 10) @paginate {
907
- edges {
908
- node {
909
- id
910
- }
911
- }
912
- }
913
- }
914
- `
915
- ),
916
- ]
917
-
918
- // run the pipeline
919
- const config = testConfig()
920
- await runPipeline(config, docs)
921
-
922
- // load the contents of the file
923
- expect(docs[0]?.document).toMatchInlineSnapshot(`
924
- query Users($last: Int = 10, $before: String) {
925
- usersByBackwardsCursor(last: $last, before: $before) @paginate {
926
- edges {
927
- node {
928
- id
929
- }
930
- }
931
- edges {
932
- cursor
933
- node {
934
- __typename
935
- }
936
- }
937
- pageInfo {
938
- hasPreviousPage
939
- hasNextPage
940
- startCursor
941
- endCursor
942
- }
943
- }
944
- }
945
-
946
- `)
947
- })
948
-
949
- test('query with offset paginate', async function () {
950
- const docs = [
951
- mockCollectedDoc(
952
- `
953
- query Users {
954
- usersByOffset(limit: 10) @paginate {
955
- id
956
- }
957
- }
958
- `
959
- ),
960
- ]
961
-
962
- // run the pipeline
963
- const config = testConfig()
964
- await runPipeline(config, docs)
965
-
966
- // load the contents of the file
967
- expect(docs[0]?.document).toMatchInlineSnapshot(`
968
- query Users($limit: Int = 10, $offset: Int) {
969
- usersByOffset(limit: $limit, offset: $offset) @paginate {
970
- id
971
- }
972
- }
973
-
974
- `)
975
- })
976
-
977
- test('query with backwards cursor on full paginate', async function () {
978
- const docs = [
979
- mockCollectedDoc(
980
- `
981
- query Users {
982
- usersByCursor(last: 10) @paginate {
983
- edges {
984
- node {
985
- id
986
- }
987
- }
988
- }
989
- }
990
- `
991
- ),
992
- ]
993
-
994
- // run the pipeline
995
- const config = testConfig()
996
- await runPipeline(config, docs)
997
-
998
- // load the contents of the file
999
- expect(docs[0]?.document).toMatchInlineSnapshot(`
1000
- query Users($last: Int = 10, $before: String) {
1001
- usersByCursor(last: $last, before: $before) @paginate {
1002
- edges {
1003
- node {
1004
- id
1005
- }
1006
- }
1007
- edges {
1008
- cursor
1009
- node {
1010
- __typename
1011
- }
1012
- }
1013
- pageInfo {
1014
- hasPreviousPage
1015
- hasNextPage
1016
- startCursor
1017
- endCursor
1018
- }
1019
- }
1020
- }
1021
-
1022
- `)
1023
- })
1024
-
1025
- test('query with forwards cursor on full paginate', async function () {
1026
- const docs = [
1027
- mockCollectedDoc(
1028
- `
1029
- query Users {
1030
- usersByCursor(first: 10) @paginate {
1031
- edges {
1032
- node {
1033
- id
1034
- }
1035
- }
1036
- }
1037
- }
1038
- `
1039
- ),
1040
- ]
1041
-
1042
- // run the pipeline
1043
- const config = testConfig()
1044
- await runPipeline(config, docs)
1045
-
1046
- // load the contents of the file
1047
- expect(docs[0]?.document).toMatchInlineSnapshot(`
1048
- query Users($first: Int = 10, $after: String) {
1049
- usersByCursor(first: $first, after: $after) @paginate {
1050
- edges {
1051
- node {
1052
- id
1053
- }
1054
- }
1055
- edges {
1056
- cursor
1057
- node {
1058
- __typename
1059
- }
1060
- }
1061
- pageInfo {
1062
- hasPreviousPage
1063
- hasNextPage
1064
- startCursor
1065
- endCursor
1066
- }
1067
- }
1068
- }
1069
-
1070
- `)
1071
- })
1072
-
1073
- test("forwards cursor paginated query doesn't overlap variables", async function () {
1074
- const docs = [
1075
- mockCollectedDoc(
1076
- `
1077
- query Users($first: Int!) {
1078
- usersByCursor(first: $first) @paginate {
1079
- edges {
1080
- node {
1081
- id
1082
- }
1083
- }
1084
- }
1085
- }
1086
- `
1087
- ),
1088
- ]
1089
-
1090
- // run the pipeline
1091
- const config = testConfig()
1092
- await runPipeline(config, docs)
1093
-
1094
- // load the contents of the file
1095
- expect(docs[0]?.document).toMatchInlineSnapshot(`
1096
- query Users($first: Int!, $after: String) {
1097
- usersByCursor(first: $first, after: $after) @paginate {
1098
- edges {
1099
- node {
1100
- id
1101
- }
1102
- }
1103
- edges {
1104
- cursor
1105
- node {
1106
- __typename
1107
- }
1108
- }
1109
- pageInfo {
1110
- hasPreviousPage
1111
- hasNextPage
1112
- startCursor
1113
- endCursor
1114
- }
1115
- }
1116
- }
1117
-
1118
- `)
1119
- })
1120
-
1121
- test("backwards cursor paginated query doesn't overlap variables", async function () {
1122
- const docs = [
1123
- mockCollectedDoc(
1124
- `
1125
- query Users($last: Int!) {
1126
- usersByCursor(last: $last) @paginate {
1127
- edges {
1128
- node {
1129
- id
1130
- }
1131
- }
1132
- }
1133
- }
1134
- `
1135
- ),
1136
- ]
1137
-
1138
- // run the pipeline
1139
- const config = testConfig()
1140
- await runPipeline(config, docs)
1141
-
1142
- // load the contents of the file
1143
- expect(docs[0]?.document).toMatchInlineSnapshot(`
1144
- query Users($last: Int!, $before: String) {
1145
- usersByCursor(last: $last, before: $before) @paginate {
1146
- edges {
1147
- node {
1148
- id
1149
- }
1150
- }
1151
- edges {
1152
- cursor
1153
- node {
1154
- __typename
1155
- }
1156
- }
1157
- pageInfo {
1158
- hasPreviousPage
1159
- hasNextPage
1160
- startCursor
1161
- endCursor
1162
- }
1163
- }
1164
- }
1165
-
1166
- `)
1167
- })
1168
-
1169
- test("offset paginated query doesn't overlap variables", async function () {
1170
- const docs = [
1171
- mockCollectedDoc(
1172
- `
1173
- query Users($limit: Int! = 10) {
1174
- usersByOffset(limit: $limit) @paginate {
1175
- id
1176
- }
1177
- }
1178
- `
1179
- ),
1180
- ]
1181
-
1182
- // run the pipeline
1183
- const config = testConfig()
1184
- await runPipeline(config, docs)
1185
-
1186
- // load the contents of the file
1187
- expect(docs[0]?.document).toMatchInlineSnapshot(`
1188
- query Users($limit: Int! = 10, $offset: Int) {
1189
- usersByOffset(limit: $limit, offset: $offset) @paginate {
1190
- id
1191
- }
1192
- }
1193
-
1194
- `)
1195
- })
1196
-
1197
- test('refetch specification with backwards pagination', async function () {
1198
- const docs = [
1199
- mockCollectedDoc(
1200
- `
1201
- fragment UserFriends on Query {
1202
- usersByCursor(last: 10) @paginate {
1203
- edges {
1204
- node {
1205
- id
1206
- }
1207
- }
1208
- }
1209
- }
1210
- `
1211
- ),
1212
- ]
1213
-
1214
- // run the pipeline
1215
- const config = testConfig()
1216
- await runPipeline(config, docs)
1217
-
1218
- expect(docs[0].refetch).toMatchInlineSnapshot(`
1219
- {
1220
- "update": "prepend",
1221
- "path": [
1222
- "usersByCursor"
1223
- ],
1224
- "method": "cursor",
1225
- "pageSize": 10,
1226
- "embedded": false,
1227
- "targetType": "Query",
1228
- "paginated": true,
1229
- "direction": "backwards"
1230
- }
1231
- `)
1232
- })
1233
-
1234
- test('refetch entry with initial backwards', async function () {
1235
- const docs = [
1236
- mockCollectedDoc(
1237
- `
1238
- fragment UserFriends on Query {
1239
- usersByCursor(last: 10, before: "1234") @paginate {
1240
- edges {
1241
- node {
1242
- id
1243
- }
1244
- }
1245
- }
1246
- }
1247
- `
1248
- ),
1249
- ]
1250
-
1251
- // run the pipeline
1252
- const config = testConfig()
1253
- await runPipeline(config, docs)
1254
-
1255
- expect(docs[0].refetch).toMatchInlineSnapshot(`
1256
- {
1257
- "update": "prepend",
1258
- "path": [
1259
- "usersByCursor"
1260
- ],
1261
- "method": "cursor",
1262
- "pageSize": 10,
1263
- "embedded": false,
1264
- "targetType": "Query",
1265
- "paginated": true,
1266
- "direction": "backwards",
1267
- "start": "1234"
1268
- }
1269
- `)
1270
- })
1271
-
1272
- test('refetch entry with initial forwards', async function () {
1273
- const docs = [
1274
- mockCollectedDoc(
1275
- `
1276
- fragment UserFriends on Query {
1277
- usersByCursor(first: 10, after: "1234") @paginate {
1278
- edges {
1279
- node {
1280
- id
1281
- }
1282
- }
1283
- }
1284
- }
1285
- `
1286
- ),
1287
- ]
1288
-
1289
- // run the pipeline
1290
- const config = testConfig()
1291
- await runPipeline(config, docs)
1292
-
1293
- expect(docs[0].refetch).toMatchInlineSnapshot(`
1294
- {
1295
- "update": "append",
1296
- "path": [
1297
- "usersByCursor"
1298
- ],
1299
- "method": "cursor",
1300
- "pageSize": 10,
1301
- "embedded": false,
1302
- "targetType": "Query",
1303
- "paginated": true,
1304
- "direction": "forward",
1305
- "start": "1234"
1306
- }
1307
- `)
1308
- })
1309
-
1310
- test('generated query has same refetch spec', async function () {
1311
- const docs = [
1312
- mockCollectedDoc(
1313
- `
1314
- fragment UserFriends on Query {
1315
- usersByCursor(first: 10, after: "1234") @paginate {
1316
- edges {
1317
- node {
1318
- id
1319
- }
1320
- }
1321
- }
1322
- }
1323
- `
1324
- ),
1325
- ]
1326
-
1327
- // run the pipeline
1328
- const config = testConfig()
1329
- await runPipeline(config, docs)
1330
-
1331
- await expect(docs[1]).toMatchInlineSnapshot(`
1332
- export default {
1333
- name: "UserFriends_Pagination_Query",
1334
- kind: "HoudiniQuery",
1335
- hash: "5aeb471edf15c5b3e709ddccc6014f073d2dfdc1259d04b7ee26887ea81ef23b",
1336
-
1337
- refetch: {
1338
- update: "append",
1339
- path: ["usersByCursor"],
1340
- method: "cursor",
1341
- pageSize: 10,
1342
- embedded: false,
1343
- targetType: "Query",
1344
- paginated: true,
1345
- direction: "forward",
1346
- start: "1234"
1347
- },
1348
-
1349
- raw: \`query UserFriends_Pagination_Query($first: Int = 10, $after: String = "1234") {
1350
- ...UserFriends_jrGTj
1351
- }
1352
-
1353
- fragment UserFriends_jrGTj on Query {
1354
- usersByCursor(first: $first, after: $after) {
1355
- edges {
1356
- node {
1357
- id
1358
- }
1359
- }
1360
- edges {
1361
- cursor
1362
- node {
1363
- __typename
1364
- }
1365
- }
1366
- pageInfo {
1367
- hasPreviousPage
1368
- hasNextPage
1369
- startCursor
1370
- endCursor
1371
- }
1372
- }
1373
- }
1374
- \`,
1375
-
1376
- rootType: "Query",
1377
-
1378
- selection: {
1379
- usersByCursor: {
1380
- type: "UserConnection",
1381
- keyRaw: "usersByCursor::paginated",
1382
-
1383
- fields: {
1384
- edges: {
1385
- type: "UserEdge",
1386
- keyRaw: "edges",
1387
-
1388
- fields: {
1389
- cursor: {
1390
- type: "String",
1391
- keyRaw: "cursor"
1392
- },
1393
-
1394
- node: {
1395
- type: "User",
1396
- keyRaw: "node",
1397
- nullable: true,
1398
-
1399
- fields: {
1400
- __typename: {
1401
- type: "String",
1402
- keyRaw: "__typename"
1403
- },
1404
-
1405
- id: {
1406
- type: "ID",
1407
- keyRaw: "id"
1408
- }
1409
- }
1410
- }
1411
- },
1412
-
1413
- update: "append"
1414
- },
1415
-
1416
- pageInfo: {
1417
- type: "PageInfo",
1418
- keyRaw: "pageInfo",
1419
-
1420
- fields: {
1421
- hasPreviousPage: {
1422
- type: "Boolean",
1423
- keyRaw: "hasPreviousPage"
1424
- },
1425
-
1426
- hasNextPage: {
1427
- type: "Boolean",
1428
- keyRaw: "hasNextPage"
1429
- },
1430
-
1431
- startCursor: {
1432
- type: "String",
1433
- keyRaw: "startCursor"
1434
- },
1435
-
1436
- endCursor: {
1437
- type: "String",
1438
- keyRaw: "endCursor"
1439
- }
1440
- }
1441
- }
1442
- }
1443
- }
1444
- },
1445
-
1446
- input: {
1447
- fields: {
1448
- first: "Int",
1449
- after: "String"
1450
- },
1451
-
1452
- types: {}
1453
- },
1454
-
1455
- policy: "CacheOrNetwork",
1456
- partial: false
1457
- };
1458
-
1459
- "HoudiniHash=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
1460
- `)
1461
- })
1462
-
1463
- test('refetch specification with offset pagination', async function () {
1464
- const docs = [
1465
- mockCollectedDoc(
1466
- `
1467
- fragment UserFriends on Query {
1468
- usersByOffset(limit: 10) @paginate {
1469
- id
1470
- }
1471
- }
1472
- `
1473
- ),
1474
- ]
1475
-
1476
- // run the pipeline
1477
- const config = testConfig()
1478
- await runPipeline(config, docs)
1479
-
1480
- expect(docs[0].refetch).toMatchInlineSnapshot(`
1481
- {
1482
- "update": "append",
1483
- "path": [
1484
- "usersByOffset"
1485
- ],
1486
- "method": "offset",
1487
- "pageSize": 10,
1488
- "embedded": false,
1489
- "targetType": "Query",
1490
- "paginated": true,
1491
- "direction": "forward"
1492
- }
1493
- `)
1494
- })
1495
-
1496
- test('refetch specification with initial offset', async function () {
1497
- const docs = [
1498
- mockCollectedDoc(
1499
- `
1500
- fragment UserFriends on Query {
1501
- usersByOffset(limit: 10, offset: 10) @paginate {
1502
- id
1503
- }
1504
- }
1505
- `
1506
- ),
1507
- ]
1508
-
1509
- // run the pipeline
1510
- const config = testConfig()
1511
- await runPipeline(config, docs)
1512
-
1513
- expect(docs[0].refetch).toMatchInlineSnapshot(`
1514
- {
1515
- "update": "append",
1516
- "path": [
1517
- "usersByOffset"
1518
- ],
1519
- "method": "offset",
1520
- "pageSize": 10,
1521
- "embedded": false,
1522
- "targetType": "Query",
1523
- "paginated": true,
1524
- "direction": "forward",
1525
- "start": 10
1526
- }
1527
- `)
1528
- })