houdini 1.0.6 → 1.0.8

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.
@@ -45406,14 +45406,18 @@ var require_lib3 = __commonJS({
45406
45406
  }
45407
45407
  });
45408
45408
 
45409
- // ../../node_modules/.pnpm/tslib@2.4.1/node_modules/tslib/tslib.js
45409
+ // ../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js
45410
45410
  var require_tslib = __commonJS({
45411
- "../../node_modules/.pnpm/tslib@2.4.1/node_modules/tslib/tslib.js"(exports, module) {
45411
+ "../../node_modules/.pnpm/tslib@2.5.0/node_modules/tslib/tslib.js"(exports, module) {
45412
45412
  var __extends;
45413
45413
  var __assign;
45414
45414
  var __rest;
45415
45415
  var __decorate;
45416
45416
  var __param;
45417
+ var __esDecorate;
45418
+ var __runInitializers;
45419
+ var __propKey;
45420
+ var __setFunctionName;
45417
45421
  var __metadata;
45418
45422
  var __awaiter;
45419
45423
  var __generator;
@@ -45510,6 +45514,65 @@ var require_tslib = __commonJS({
45510
45514
  decorator(target, key, paramIndex);
45511
45515
  };
45512
45516
  };
45517
+ __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
45518
+ function accept(f3) {
45519
+ if (f3 !== void 0 && typeof f3 !== "function")
45520
+ throw new TypeError("Function expected");
45521
+ return f3;
45522
+ }
45523
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
45524
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
45525
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
45526
+ var _, done = false;
45527
+ for (var i2 = decorators.length - 1; i2 >= 0; i2--) {
45528
+ var context = {};
45529
+ for (var p in contextIn)
45530
+ context[p] = p === "access" ? {} : contextIn[p];
45531
+ for (var p in contextIn.access)
45532
+ context.access[p] = contextIn.access[p];
45533
+ context.addInitializer = function(f3) {
45534
+ if (done)
45535
+ throw new TypeError("Cannot add initializers after decoration has completed");
45536
+ extraInitializers.push(accept(f3 || null));
45537
+ };
45538
+ var result = (0, decorators[i2])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
45539
+ if (kind === "accessor") {
45540
+ if (result === void 0)
45541
+ continue;
45542
+ if (result === null || typeof result !== "object")
45543
+ throw new TypeError("Object expected");
45544
+ if (_ = accept(result.get))
45545
+ descriptor.get = _;
45546
+ if (_ = accept(result.set))
45547
+ descriptor.set = _;
45548
+ if (_ = accept(result.init))
45549
+ initializers.push(_);
45550
+ } else if (_ = accept(result)) {
45551
+ if (kind === "field")
45552
+ initializers.push(_);
45553
+ else
45554
+ descriptor[key] = _;
45555
+ }
45556
+ }
45557
+ if (target)
45558
+ Object.defineProperty(target, contextIn.name, descriptor);
45559
+ done = true;
45560
+ };
45561
+ __runInitializers = function(thisArg, initializers, value) {
45562
+ var useValue = arguments.length > 2;
45563
+ for (var i2 = 0; i2 < initializers.length; i2++) {
45564
+ value = useValue ? initializers[i2].call(thisArg, value) : initializers[i2].call(thisArg);
45565
+ }
45566
+ return useValue ? value : void 0;
45567
+ };
45568
+ __propKey = function(x2) {
45569
+ return typeof x2 === "symbol" ? x2 : "".concat(x2);
45570
+ };
45571
+ __setFunctionName = function(f3, name, prefix) {
45572
+ if (typeof name === "symbol")
45573
+ name = name.description ? "[".concat(name.description, "]") : "";
45574
+ return Object.defineProperty(f3, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
45575
+ };
45513
45576
  __metadata = function(metadataKey, metadataValue) {
45514
45577
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
45515
45578
  return Reflect.metadata(metadataKey, metadataValue);
@@ -45744,7 +45807,7 @@ var require_tslib = __commonJS({
45744
45807
  }, i2;
45745
45808
  function verb(n, f3) {
45746
45809
  i2[n] = o[n] ? function(v) {
45747
- return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f3 ? f3(v) : v;
45810
+ return (p = !p) ? { value: __await(o[n](v)), done: false } : f3 ? f3(v) : v;
45748
45811
  } : f3;
45749
45812
  }
45750
45813
  };
@@ -45822,6 +45885,10 @@ var require_tslib = __commonJS({
45822
45885
  exporter("__rest", __rest);
45823
45886
  exporter("__decorate", __decorate);
45824
45887
  exporter("__param", __param);
45888
+ exporter("__esDecorate", __esDecorate);
45889
+ exporter("__runInitializers", __runInitializers);
45890
+ exporter("__propKey", __propKey);
45891
+ exporter("__setFunctionName", __setFunctionName);
45825
45892
  exporter("__metadata", __metadata);
45826
45893
  exporter("__awaiter", __awaiter);
45827
45894
  exporter("__generator", __generator);
@@ -65329,6 +65396,10 @@ var CachePolicy = {
65329
65396
  NetworkOnly: "NetworkOnly",
65330
65397
  CacheAndNetwork: "CacheAndNetwork"
65331
65398
  };
65399
+ var PaginateMode = {
65400
+ Infinite: "Infinite",
65401
+ SinglePage: "SinglePage"
65402
+ };
65332
65403
  var ArtifactKind = {
65333
65404
  Query: "HoudiniQuery",
65334
65405
  Subscription: "HoudiniSubscription",
@@ -68938,6 +69009,7 @@ var Config = class {
68938
69009
  defaultPartial;
68939
69010
  internalListPosition;
68940
69011
  defaultListTarget = null;
69012
+ defaultPaginateMode;
68941
69013
  definitionsFolder;
68942
69014
  newDocuments = "";
68943
69015
  defaultKeys = ["id"];
@@ -68974,6 +69046,7 @@ var Config = class {
68974
69046
  defaultPartial = false,
68975
69047
  defaultListPosition = "append",
68976
69048
  defaultListTarget = null,
69049
+ defaultPaginateMode = PaginateMode.Infinite,
68977
69050
  defaultKeys,
68978
69051
  types: types17 = {},
68979
69052
  logLevel,
@@ -69007,6 +69080,7 @@ var Config = class {
69007
69080
  this.defaultPartial = defaultPartial;
69008
69081
  this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
69009
69082
  this.defaultListTarget = defaultListTarget;
69083
+ this.defaultPaginateMode = defaultPaginateMode;
69010
69084
  this.definitionsFolder = definitionsPath;
69011
69085
  this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
69012
69086
  this.defaultFragmentMasking = defaultFragmentMasking;
@@ -69270,7 +69344,7 @@ var Config = class {
69270
69344
  get listAllListsDirective() {
69271
69345
  return "allLists";
69272
69346
  }
69273
- get listNameArg() {
69347
+ get listOrPaginateNameArg() {
69274
69348
  return "name";
69275
69349
  }
69276
69350
  get insertFragmentSuffix() {
@@ -69303,8 +69377,8 @@ var Config = class {
69303
69377
  get paginateDirective() {
69304
69378
  return "paginate";
69305
69379
  }
69306
- get paginateNameArg() {
69307
- return "name";
69380
+ get paginateModeArg() {
69381
+ return "mode";
69308
69382
  }
69309
69383
  get cacheDirective() {
69310
69384
  return "cache";
@@ -69346,7 +69420,7 @@ var Config = class {
69346
69420
  return name + this.removeFragmentSuffix;
69347
69421
  }
69348
69422
  isInternalEnum(node) {
69349
- return node.name.value === "CachePolicy";
69423
+ return node.name.value === "CachePolicy" || node.name.value === "PaginateMode";
69350
69424
  }
69351
69425
  isInternalDirective(name) {
69352
69426
  const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
@@ -71113,6 +71187,7 @@ async function paginate(config4, documents) {
71113
71187
  let refetchQueryName = "";
71114
71188
  let nodeQuery = false;
71115
71189
  let fragment = "";
71190
+ let paginateMode = config4.defaultPaginateMode;
71116
71191
  doc.document = graphql10.visit(doc.document, {
71117
71192
  OperationDefinition(node) {
71118
71193
  if (node.operation !== "query") {
@@ -71178,6 +71253,14 @@ async function paginate(config4, documents) {
71178
71253
  }
71179
71254
  },
71180
71255
  Directive(node) {
71256
+ if (node.name.value === config4.paginateDirective) {
71257
+ const paginateModeArg = node?.arguments?.find(
71258
+ (arg) => arg.name.value === config4.paginateModeArg
71259
+ );
71260
+ if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
71261
+ paginateMode = paginateModeArg.value.value;
71262
+ }
71263
+ }
71181
71264
  if (node.name.value !== config4.argumentsDirective) {
71182
71265
  return;
71183
71266
  }
@@ -71222,7 +71305,8 @@ async function paginate(config4, documents) {
71222
71305
  targetType,
71223
71306
  paginated: true,
71224
71307
  direction,
71225
- start
71308
+ start,
71309
+ mode: paginateMode
71226
71310
  };
71227
71311
  if (!fragment) {
71228
71312
  continue;
@@ -71571,7 +71655,9 @@ async function addListFragments(config4, documents) {
71571
71655
  doc.document = graphql11.visit(doc.document, {
71572
71656
  Directive(node, key, parent, path2, ancestors) {
71573
71657
  if ([config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
71574
- const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
71658
+ const nameArg = node.arguments?.find(
71659
+ (arg) => arg.name.value === config4.listOrPaginateNameArg
71660
+ );
71575
71661
  let error = {
71576
71662
  ...new graphql11.GraphQLError(
71577
71663
  "",
@@ -71871,14 +71957,23 @@ function fieldKey(config4, field) {
71871
71957
  const attributeName = field.alias?.value || field.name.value;
71872
71958
  const printed = graphql12.print(field);
71873
71959
  const secondParse = graphql12.parse(`{${printed}}`).definitions[0].selectionSet.selections[0];
71874
- const paginated = !!field.directives?.find(
71960
+ let paginateMode = config4.defaultPaginateMode;
71961
+ const paginatedDirective = field.directives?.find(
71875
71962
  (directive) => directive.name.value === config4.paginateDirective
71876
71963
  );
71877
- const paginationArgs = ["first", "after", "last", "before", "limit", "offset"];
71964
+ if (paginatedDirective) {
71965
+ const paginateModeArg = paginatedDirective?.arguments?.find(
71966
+ (arg) => arg.name.value === config4.paginateModeArg
71967
+ );
71968
+ if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
71969
+ paginateMode = paginateModeArg.value.value;
71970
+ }
71971
+ }
71972
+ const paginationArgs = paginateMode === "SinglePage" ? [] : ["first", "after", "last", "before", "limit", "offset"];
71878
71973
  const argObj = (secondParse.arguments || []).reduce((acc, arg) => {
71879
71974
  const start = arg.value.loc?.start;
71880
71975
  const end = arg.value.loc?.end;
71881
- if (paginated && paginationArgs.includes(arg.name.value)) {
71976
+ if (paginatedDirective && paginationArgs.includes(arg.name.value)) {
71882
71977
  return acc;
71883
71978
  }
71884
71979
  if (!start || !end) {
@@ -71892,7 +71987,7 @@ function fieldKey(config4, field) {
71892
71987
  const args = Object.keys(argObj);
71893
71988
  args.sort();
71894
71989
  let key = Object.values(argObj).length > 0 ? `${attributeName}(${args.map((key2) => `${key2}: ${argObj[key2]}`).join(", ")})` : attributeName;
71895
- if (paginated) {
71990
+ if (paginatedDirective) {
71896
71991
  key = key + "::paginated";
71897
71992
  }
71898
71993
  return key;
@@ -72032,7 +72127,9 @@ function selection({
72032
72127
  const listDirective = field.directives?.find(
72033
72128
  (directive) => [config4.listDirective, config4.paginateDirective].includes(directive.name.value)
72034
72129
  );
72035
- const nameArg = listDirective?.arguments?.find((arg) => arg.name.value === "name");
72130
+ const nameArg = listDirective?.arguments?.find(
72131
+ (arg) => arg.name.value === config4.listOrPaginateNameArg
72132
+ );
72036
72133
  if (nameArg && nameArg.value.kind === "StringValue") {
72037
72134
  const { connection, type: connectionType } = connectionSelection(
72038
72135
  config4,
@@ -72151,7 +72248,7 @@ function artifactGenerator(stats) {
72151
72248
  return;
72152
72249
  }
72153
72250
  const nameArg = node.arguments?.find(
72154
- (arg) => arg.name.value === config4.listNameArg
72251
+ (arg) => arg.name.value === config4.listOrPaginateNameArg
72155
72252
  );
72156
72253
  if (!nameArg || nameArg.value.kind !== "StringValue") {
72157
72254
  throw new HoudiniError({
@@ -72819,6 +72916,12 @@ function inlineType({
72819
72916
  includeFragments,
72820
72917
  allOptional
72821
72918
  });
72919
+ const hasIncludeOrSkipDirective = selection2.directives && selection2.directives.filter(
72920
+ (directive) => directive.name.value === "include" || directive.name.value === "skip"
72921
+ ).length > 0;
72922
+ if (hasIncludeOrSkipDirective) {
72923
+ attributeType = AST10.tsUnionType([attributeType, AST10.tsUndefinedKeyword()]);
72924
+ }
72822
72925
  const prop = readonlyProperty(
72823
72926
  AST10.tsPropertySignature(
72824
72927
  AST10.identifier(attributeName),
@@ -73515,7 +73618,9 @@ function listDefinitions(config4, body, docs) {
73515
73618
  if (![config4.listDirective, config4.paginateDirective].includes(node.name.value)) {
73516
73619
  return;
73517
73620
  }
73518
- const nameArg = node.arguments?.find((arg) => arg.name.value === "name");
73621
+ const nameArg = node.arguments?.find(
73622
+ (arg) => arg.name.value === config4.listOrPaginateNameArg
73623
+ );
73519
73624
  const nameValue = nameArg?.value?.value || "";
73520
73625
  if (!nameValue || visitedLists.has(nameValue)) {
73521
73626
  return;
@@ -73840,17 +73945,22 @@ enum CachePolicy {
73840
73945
  ${CachePolicy.NetworkOnly}
73841
73946
  }
73842
73947
 
73948
+ enum PaginateMode {
73949
+ ${PaginateMode.Infinite}
73950
+ ${PaginateMode.SinglePage}
73951
+ }
73952
+
73843
73953
  """
73844
73954
  @${config4.listDirective} is used to mark a field for the runtime as a place to add or remove
73845
73955
  entities in mutations
73846
73956
  """
73847
- directive @${config4.listDirective}(${config4.listNameArg}: String!, connection: Boolean) on FIELD
73957
+ directive @${config4.listDirective}(${config4.listOrPaginateNameArg}: String!, connection: Boolean) on FIELD
73848
73958
 
73849
73959
  """
73850
73960
  @${config4.paginateDirective} is used to to mark a field for pagination.
73851
73961
  More info in the [doc](${siteURL}/guides/pagination).
73852
73962
  """
73853
- directive @${config4.paginateDirective}(${config4.paginateNameArg}: String) on FIELD
73963
+ directive @${config4.paginateDirective}(${config4.listOrPaginateNameArg}: String, ${config4.paginateModeArg}: PaginateMode) on FIELD
73854
73964
 
73855
73965
  """
73856
73966
  @${config4.listPrependDirective} is used to tell the runtime to add the result to the end of the list
@@ -74116,7 +74226,7 @@ async function typeCheck(config4, docs) {
74116
74226
  }
74117
74227
  needsParent = needsParent || definition.kind === "FragmentDefinition";
74118
74228
  const nameArg = directive.arguments?.find(
74119
- ({ name }) => name.value === config4.listNameArg
74229
+ ({ name }) => name.value === config4.listOrPaginateNameArg
74120
74230
  );
74121
74231
  if (!nameArg) {
74122
74232
  if (directive.name.value === config4.listDirective) {
@@ -74596,7 +74706,14 @@ function paginateArgs(config4, filepath) {
74596
74706
  )
74597
74707
  );
74598
74708
  }
74599
- if (forward && backwards) {
74709
+ const paginateModeArg = node?.arguments?.find(
74710
+ (arg) => arg.name.value === config4.paginateModeArg
74711
+ );
74712
+ let paginateMode = config4.defaultPaginateMode;
74713
+ if (paginateModeArg && paginateModeArg.value.kind === "EnumValue") {
74714
+ paginateMode = paginateModeArg.value.value;
74715
+ }
74716
+ if (forward && backwards && paginateMode === "Infinite") {
74600
74717
  ctx.reportError(
74601
74718
  new graphql25.GraphQLError(
74602
74719
  `A field with cursor pagination cannot go forwards an backwards simultaneously`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -22,7 +22,6 @@
22
22
  "@types/node": "^18.7.23",
23
23
  "prettier": "^2.8.3",
24
24
  "rollup": "^3.7.4",
25
- "turbo": "^1.5.4",
26
25
  "vite": "^4.1.1",
27
26
  "vitest": "^0.28.3",
28
27
  "scripts": "^1.0.0"