houdini 0.12.4 → 0.13.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/build/cmd/transforms/list.js +22 -0
  2. package/build/cmd/transforms/paginate.d.ts +34 -0
  3. package/build/cmd/transforms/paginate.js +3 -2
  4. package/build/cmd.js +903 -882
  5. package/build/runtime/cache/cache.d.ts +76 -45
  6. package/build/runtime/cache/cache.js +400 -755
  7. package/build/runtime/cache/gc.d.ts +9 -0
  8. package/build/runtime/cache/gc.js +96 -0
  9. package/build/runtime/cache/{list.d.ts → lists.d.ts} +28 -17
  10. package/build/{runtime-cjs/cache/list.js → runtime/cache/lists.js} +152 -71
  11. package/build/runtime/cache/storage.d.ts +86 -0
  12. package/build/runtime/cache/storage.js +535 -0
  13. package/build/runtime/cache/stuff.d.ts +6 -0
  14. package/build/runtime/cache/stuff.js +98 -0
  15. package/build/runtime/cache/subscription.d.ts +29 -0
  16. package/build/runtime/cache/subscription.js +384 -0
  17. package/build/runtime/fragment.js +64 -41
  18. package/build/runtime/index.d.ts +1 -0
  19. package/build/runtime/index.js +1 -0
  20. package/build/runtime/mutation.js +1 -1
  21. package/build/runtime/network.js +7 -4
  22. package/build/runtime/pagination.js +3 -1
  23. package/build/runtime/proxy.d.ts +6 -0
  24. package/build/runtime/proxy.js +52 -0
  25. package/build/runtime/query.js +5 -3
  26. package/build/runtime/types.d.ts +2 -0
  27. package/build/runtime-cjs/cache/cache.d.ts +76 -45
  28. package/build/runtime-cjs/cache/cache.js +400 -755
  29. package/build/runtime-cjs/cache/gc.d.ts +9 -0
  30. package/build/runtime-cjs/cache/gc.js +96 -0
  31. package/build/runtime-cjs/cache/{list.d.ts → lists.d.ts} +28 -17
  32. package/build/{runtime/cache/list.js → runtime-cjs/cache/lists.js} +152 -71
  33. package/build/runtime-cjs/cache/storage.d.ts +86 -0
  34. package/build/runtime-cjs/cache/storage.js +535 -0
  35. package/build/runtime-cjs/cache/stuff.d.ts +6 -0
  36. package/build/runtime-cjs/cache/stuff.js +98 -0
  37. package/build/runtime-cjs/cache/subscription.d.ts +29 -0
  38. package/build/runtime-cjs/cache/subscription.js +384 -0
  39. package/build/runtime-cjs/fragment.js +64 -41
  40. package/build/runtime-cjs/index.d.ts +1 -0
  41. package/build/runtime-cjs/index.js +1 -0
  42. package/build/runtime-cjs/mutation.js +1 -1
  43. package/build/runtime-cjs/network.js +7 -4
  44. package/build/runtime-cjs/pagination.js +3 -1
  45. package/build/runtime-cjs/proxy.d.ts +6 -0
  46. package/build/runtime-cjs/proxy.js +52 -0
  47. package/build/runtime-cjs/query.js +5 -3
  48. package/build/runtime-cjs/types.d.ts +2 -0
  49. package/build/runtime-esm/cache/cache.d.ts +76 -45
  50. package/build/runtime-esm/cache/cache.js +310 -512
  51. package/build/runtime-esm/cache/gc.d.ts +9 -0
  52. package/build/runtime-esm/cache/gc.js +38 -0
  53. package/build/runtime-esm/cache/lists.d.ts +46 -0
  54. package/build/runtime-esm/cache/lists.js +259 -0
  55. package/build/runtime-esm/cache/storage.d.ts +86 -0
  56. package/build/runtime-esm/cache/storage.js +370 -0
  57. package/build/runtime-esm/cache/stuff.d.ts +6 -0
  58. package/build/runtime-esm/cache/stuff.js +59 -0
  59. package/build/runtime-esm/cache/subscription.d.ts +29 -0
  60. package/build/runtime-esm/cache/subscription.js +217 -0
  61. package/build/runtime-esm/fragment.js +65 -39
  62. package/build/runtime-esm/index.d.ts +1 -0
  63. package/build/runtime-esm/index.js +1 -0
  64. package/build/runtime-esm/mutation.js +1 -1
  65. package/build/runtime-esm/network.js +7 -4
  66. package/build/runtime-esm/pagination.js +3 -1
  67. package/build/runtime-esm/proxy.d.ts +6 -0
  68. package/build/runtime-esm/proxy.js +25 -0
  69. package/build/runtime-esm/query.js +5 -3
  70. package/build/runtime-esm/types.d.ts +2 -0
  71. package/cmd/transforms/list.ts +42 -0
  72. package/cmd/transforms/lists.test.ts +68 -1
  73. package/cmd/transforms/paginate.ts +1 -1
  74. package/package.json +2 -2
  75. package/runtime/cache/cache.ts +420 -670
  76. package/runtime/cache/gc.ts +53 -0
  77. package/runtime/cache/{list.ts → lists.ts} +124 -47
  78. package/runtime/cache/storage.ts +489 -0
  79. package/runtime/cache/stuff.ts +77 -0
  80. package/runtime/cache/subscription.ts +300 -0
  81. package/runtime/cache/tests/{policy.test.ts → availability.test.ts} +9 -8
  82. package/runtime/cache/tests/gc.test.ts +63 -18
  83. package/runtime/cache/tests/keys.test.ts +34 -0
  84. package/runtime/cache/tests/list.test.ts +193 -153
  85. package/runtime/cache/tests/scalars.test.ts +5 -5
  86. package/runtime/cache/tests/storage.test.ts +383 -0
  87. package/runtime/cache/tests/{cache.test.ts → subscriptions.test.ts} +203 -266
  88. package/runtime/fragment.ts +74 -40
  89. package/runtime/index.ts +1 -0
  90. package/runtime/mutation.ts +1 -1
  91. package/runtime/network.ts +7 -8
  92. package/runtime/pagination.ts +6 -1
  93. package/runtime/proxy.ts +28 -0
  94. package/runtime/query.ts +5 -6
  95. package/runtime/types.ts +2 -0
  96. package/build/runtime/cache/record.d.ts +0 -40
  97. package/build/runtime/cache/record.js +0 -342
  98. package/build/runtime-cjs/cache/record.d.ts +0 -40
  99. package/build/runtime-cjs/cache/record.js +0 -342
  100. package/runtime/cache/record.ts +0 -255
@@ -105,6 +105,7 @@ var graphql = __importStar(require("graphql"));
105
105
  var types_1 = require("../types");
106
106
  var utils_1 = require("../utils");
107
107
  var types_2 = require("../../runtime/types");
108
+ var paginate_1 = require("./paginate");
108
109
  // addListFragments adds fragments for the fields tagged with @list
109
110
  function addListFragments(config, documents) {
110
111
  return __awaiter(this, void 0, void 0, function () {
@@ -177,6 +178,27 @@ function addListFragments(config, documents) {
177
178
  }
178
179
  }
179
180
  },
181
+ Field: function (node, key, parent, path, ancestors) {
182
+ var _a;
183
+ // if the is marked with @list and is a connection, we need to make sure that we ask for
184
+ // the cursor fields
185
+ if (!((_a = node.directives) === null || _a === void 0 ? void 0 : _a.find(function (directive) { return directive.name.value === config.listDirective; }))) {
186
+ return;
187
+ }
188
+ // the field is a list, is it a connection?
189
+ // look up the parent's type
190
+ var parentType = houdini_common_1.parentTypeFromAncestors(config.schema, ancestors);
191
+ // a non-connection list can just use the selection set of the tagged field
192
+ // but if this is a connection tagged with list we need to use the selection
193
+ // of the edges.node field
194
+ var targetField = node;
195
+ var targetFieldDefinition = parentType.getFields()[targetField.name.value];
196
+ var connection = connectionSelection(config, targetFieldDefinition, houdini_common_1.parentTypeFromAncestors(config.schema, ancestors), node.selectionSet).connection;
197
+ // if the field is a connection, add the cursor
198
+ if (connection) {
199
+ return __assign(__assign({}, node), { selectionSet: __assign(__assign({}, node.selectionSet), { selections: __spread(node.selectionSet.selections, paginate_1.pageInfoSelection) }) });
200
+ }
201
+ },
180
202
  });
181
203
  };
182
204
  try {
@@ -1,3 +1,37 @@
1
1
  import { Config } from 'houdini-common';
2
2
  import { CollectedGraphQLDocument } from '../types';
3
3
  export default function paginate(config: Config, documents: CollectedGraphQLDocument[]): Promise<void>;
4
+ export declare const pageInfoSelection: {
5
+ kind: string;
6
+ name: {
7
+ kind: string;
8
+ value: string;
9
+ };
10
+ selectionSet: {
11
+ kind: string;
12
+ selections: ({
13
+ kind: string;
14
+ name: {
15
+ kind: string;
16
+ value: string;
17
+ };
18
+ selectionSet?: undefined;
19
+ } | {
20
+ kind: string;
21
+ name: {
22
+ kind: string;
23
+ value: string;
24
+ };
25
+ selectionSet: {
26
+ kind: string;
27
+ selections: {
28
+ kind: string;
29
+ name: {
30
+ kind: string;
31
+ value: string;
32
+ };
33
+ }[];
34
+ };
35
+ })[];
36
+ };
37
+ }[];
@@ -97,6 +97,7 @@ var __values = (this && this.__values) || function(o) {
97
97
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
98
98
  };
99
99
  Object.defineProperty(exports, "__esModule", { value: true });
100
+ exports.pageInfoSelection = void 0;
100
101
  // externals
101
102
  var graphql = __importStar(require("graphql"));
102
103
  var houdini_common_1 = require("houdini-common");
@@ -191,7 +192,7 @@ function paginate(config, documents) {
191
192
  ? // no need to add any fields to the selection if we're dealing with offset pagination
192
193
  node.selectionSet
193
194
  : // add the page info if we are dealing with cursor-based pagination
194
- __assign(__assign({}, node.selectionSet), { selections: __spread(node.selectionSet.selections, pageInfoSelection) }) });
195
+ __assign(__assign({}, node.selectionSet), { selections: __spread(node.selectionSet.selections, exports.pageInfoSelection) }) });
195
196
  },
196
197
  });
197
198
  // if we saw the paginate directive we need to add arguments to the fragment or query that contain the
@@ -610,7 +611,7 @@ function objectNode(_a) {
610
611
  }
611
612
  return node;
612
613
  }
613
- var pageInfoSelection = [
614
+ exports.pageInfoSelection = [
614
615
  {
615
616
  kind: 'Field',
616
617
  name: {