houdini 1.0.0-next.7 → 1.0.0-next.9

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-cjs/index.js +93 -66
  2. package/build/cmd-esm/index.js +66 -39
  3. package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
  4. package/build/codegen/generators/typescript/types.d.ts +0 -1
  5. package/build/codegen-cjs/index.js +67 -39
  6. package/build/codegen-esm/index.js +54 -26
  7. package/build/lib/config.d.ts +2 -1
  8. package/build/lib/path.d.ts +1 -1
  9. package/build/lib-cjs/index.js +40 -37
  10. package/build/lib-esm/index.js +14 -11
  11. package/build/runtime/cache/cache.d.ts +6 -6
  12. package/build/runtime/cache/storage.d.ts +5 -5
  13. package/build/runtime/cache/stuff.d.ts +0 -2
  14. package/build/runtime/client/documentStore.d.ts +4 -3
  15. package/build/runtime/client/index.d.ts +6 -5
  16. package/build/runtime/client/plugins/cache.d.ts +1 -1
  17. package/build/runtime/client/plugins/fetch.d.ts +1 -1
  18. package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
  19. package/build/runtime/client/plugins/injectedPlugins.d.ts +2 -1
  20. package/build/runtime/client/plugins/mutation.d.ts +1 -1
  21. package/build/runtime/client/plugins/query.d.ts +1 -1
  22. package/build/runtime/client/plugins/subscription.d.ts +1 -1
  23. package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
  24. package/build/runtime/client/utils/documentPlugins.d.ts +2 -2
  25. package/build/runtime/lib/flatten.d.ts +2 -0
  26. package/build/runtime/lib/types.d.ts +2 -0
  27. package/build/runtime/public/record.d.ts +1 -2
  28. package/build/runtime-cjs/cache/cache.d.ts +6 -6
  29. package/build/runtime-cjs/cache/cache.js +6 -5
  30. package/build/runtime-cjs/cache/lists.js +3 -3
  31. package/build/runtime-cjs/cache/storage.d.ts +5 -5
  32. package/build/runtime-cjs/cache/storage.js +2 -2
  33. package/build/runtime-cjs/cache/stuff.d.ts +0 -2
  34. package/build/runtime-cjs/cache/stuff.js +2 -19
  35. package/build/runtime-cjs/cache/subscription.js +5 -4
  36. package/build/runtime-cjs/client/documentStore.d.ts +4 -3
  37. package/build/runtime-cjs/client/documentStore.js +4 -4
  38. package/build/runtime-cjs/client/index.d.ts +6 -5
  39. package/build/runtime-cjs/client/index.js +45 -19
  40. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  41. package/build/runtime-cjs/client/plugins/cache.js +3 -3
  42. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
  43. package/build/runtime-cjs/client/plugins/fetch.js +7 -7
  44. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
  45. package/build/runtime-cjs/client/plugins/fetchParams.js +3 -3
  46. package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +2 -1
  47. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
  48. package/build/runtime-cjs/client/plugins/mutation.js +3 -3
  49. package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
  50. package/build/runtime-cjs/client/plugins/query.js +3 -3
  51. package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -1
  52. package/build/runtime-cjs/client/plugins/subscription.js +3 -3
  53. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
  54. package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
  55. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +2 -2
  56. package/build/runtime-cjs/lib/flatten.d.ts +2 -0
  57. package/build/runtime-cjs/lib/flatten.js +41 -0
  58. package/build/runtime-cjs/lib/types.d.ts +2 -0
  59. package/build/runtime-cjs/public/cache.js +2 -2
  60. package/build/runtime-cjs/public/record.d.ts +1 -2
  61. package/build/runtime-cjs/public/record.js +1 -2
  62. package/build/runtime-esm/cache/cache.d.ts +6 -6
  63. package/build/runtime-esm/cache/cache.js +7 -6
  64. package/build/runtime-esm/cache/lists.js +3 -3
  65. package/build/runtime-esm/cache/storage.d.ts +5 -5
  66. package/build/runtime-esm/cache/storage.js +2 -2
  67. package/build/runtime-esm/cache/stuff.d.ts +0 -2
  68. package/build/runtime-esm/cache/stuff.js +1 -17
  69. package/build/runtime-esm/cache/subscription.js +6 -5
  70. package/build/runtime-esm/client/documentStore.d.ts +4 -3
  71. package/build/runtime-esm/client/documentStore.js +5 -5
  72. package/build/runtime-esm/client/index.d.ts +6 -5
  73. package/build/runtime-esm/client/index.js +46 -21
  74. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  75. package/build/runtime-esm/client/plugins/cache.js +2 -2
  76. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
  77. package/build/runtime-esm/client/plugins/fetch.js +6 -6
  78. package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
  79. package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
  80. package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +2 -1
  81. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
  82. package/build/runtime-esm/client/plugins/mutation.js +2 -2
  83. package/build/runtime-esm/client/plugins/query.d.ts +1 -1
  84. package/build/runtime-esm/client/plugins/query.js +2 -2
  85. package/build/runtime-esm/client/plugins/subscription.d.ts +1 -1
  86. package/build/runtime-esm/client/plugins/subscription.js +2 -2
  87. package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
  88. package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
  89. package/build/runtime-esm/client/utils/documentPlugins.d.ts +2 -2
  90. package/build/runtime-esm/lib/flatten.d.ts +2 -0
  91. package/build/runtime-esm/lib/flatten.js +17 -0
  92. package/build/runtime-esm/lib/types.d.ts +2 -0
  93. package/build/runtime-esm/public/cache.js +2 -2
  94. package/build/runtime-esm/public/record.d.ts +1 -2
  95. package/build/runtime-esm/public/record.js +1 -2
  96. package/build/test-cjs/index.js +67 -39
  97. package/build/test-esm/index.js +54 -26
  98. package/build/vite-cjs/index.js +90 -58
  99. package/build/vite-esm/index.js +64 -32
  100. package/package.json +4 -4
@@ -7500,7 +7500,7 @@ var require_definition = __commonJS({
7500
7500
  exports.assertInterfaceType = assertInterfaceType;
7501
7501
  exports.isUnionType = isUnionType13;
7502
7502
  exports.assertUnionType = assertUnionType;
7503
- exports.isEnumType = isEnumType10;
7503
+ exports.isEnumType = isEnumType11;
7504
7504
  exports.assertEnumType = assertEnumType;
7505
7505
  exports.isInputObjectType = isInputObjectType8;
7506
7506
  exports.assertInputObjectType = assertInputObjectType;
@@ -7571,7 +7571,7 @@ var require_definition = __commonJS({
7571
7571
  return Constructor;
7572
7572
  }
7573
7573
  function isType(type) {
7574
- return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType10(type) || isInputObjectType8(type) || isListType8(type) || isNonNullType10(type);
7574
+ return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType11(type) || isInputObjectType8(type) || isListType8(type) || isNonNullType10(type);
7575
7575
  }
7576
7576
  function assertType(type) {
7577
7577
  if (!isType(type)) {
@@ -7615,11 +7615,11 @@ var require_definition = __commonJS({
7615
7615
  }
7616
7616
  return type;
7617
7617
  }
7618
- function isEnumType10(type) {
7618
+ function isEnumType11(type) {
7619
7619
  return (0, _instanceOf.default)(type, GraphQLEnumType4);
7620
7620
  }
7621
7621
  function assertEnumType(type) {
7622
- if (!isEnumType10(type)) {
7622
+ if (!isEnumType11(type)) {
7623
7623
  throw new Error("Expected ".concat((0, _inspect.default)(type), " to be a GraphQL Enum type."));
7624
7624
  }
7625
7625
  return type;
@@ -7652,7 +7652,7 @@ var require_definition = __commonJS({
7652
7652
  return type;
7653
7653
  }
7654
7654
  function isInputType(type) {
7655
- return isScalarType13(type) || isEnumType10(type) || isInputObjectType8(type) || isWrappingType(type) && isInputType(type.ofType);
7655
+ return isScalarType13(type) || isEnumType11(type) || isInputObjectType8(type) || isWrappingType(type) && isInputType(type.ofType);
7656
7656
  }
7657
7657
  function assertInputType(type) {
7658
7658
  if (!isInputType(type)) {
@@ -7661,7 +7661,7 @@ var require_definition = __commonJS({
7661
7661
  return type;
7662
7662
  }
7663
7663
  function isOutputType(type) {
7664
- return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType10(type) || isWrappingType(type) && isOutputType(type.ofType);
7664
+ return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType11(type) || isWrappingType(type) && isOutputType(type.ofType);
7665
7665
  }
7666
7666
  function assertOutputType(type) {
7667
7667
  if (!isOutputType(type)) {
@@ -7670,7 +7670,7 @@ var require_definition = __commonJS({
7670
7670
  return type;
7671
7671
  }
7672
7672
  function isLeafType4(type) {
7673
- return isScalarType13(type) || isEnumType10(type);
7673
+ return isScalarType13(type) || isEnumType11(type);
7674
7674
  }
7675
7675
  function assertLeafType(type) {
7676
7676
  if (!isLeafType4(type)) {
@@ -7758,7 +7758,7 @@ var require_definition = __commonJS({
7758
7758
  }
7759
7759
  }
7760
7760
  function isNamedType4(type) {
7761
- return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType10(type) || isInputObjectType8(type);
7761
+ return isScalarType13(type) || isObjectType12(type) || isInterfaceType12(type) || isUnionType13(type) || isEnumType11(type) || isInputObjectType8(type);
7762
7762
  }
7763
7763
  function assertNamedType(type) {
7764
7764
  if (!isNamedType4(type)) {
@@ -65180,7 +65180,7 @@ function mergeSchemas(config4) {
65180
65180
  // src/lib/config.ts
65181
65181
  var graphql2 = __toESM(require_graphql2(), 1);
65182
65182
  var import_minimatch = __toESM(require_minimatch(), 1);
65183
- import { fileURLToPath, pathToFileURL } from "url";
65183
+ import { fileURLToPath, pathToFileURL } from "node:url";
65184
65184
 
65185
65185
  // src/runtime/lib/config.ts
65186
65186
  function defaultConfigValues(file) {
@@ -65285,8 +65285,8 @@ __export(fs_exports, {
65285
65285
  var import_fs_extra = __toESM(require_lib(), 1);
65286
65286
  var import_glob = __toESM(require_glob(), 1);
65287
65287
  var import_memfs = __toESM(require_lib2(), 1);
65288
- import fs from "fs/promises";
65289
- import { promisify } from "util";
65288
+ import fs from "node:fs/promises";
65289
+ import { promisify } from "node:util";
65290
65290
 
65291
65291
  // src/lib/path.ts
65292
65292
  var path_exports = {};
@@ -65303,8 +65303,8 @@ __export(path_exports, {
65303
65303
  resolve: () => resolve,
65304
65304
  sep: () => sep
65305
65305
  });
65306
- import os from "os";
65307
- import path from "path";
65306
+ import os from "node:os";
65307
+ import path from "node:path";
65308
65308
  var sep = "/";
65309
65309
  function resolve(...parts) {
65310
65310
  return posixify(path.resolve(...parts));
@@ -67295,13 +67295,16 @@ var pendingConfigPromise = null;
67295
67295
  async function getConfig({
67296
67296
  configPath = DEFAULT_CONFIG_PATH,
67297
67297
  noSchema,
67298
+ forceReload,
67298
67299
  ...extraConfig
67299
67300
  } = {}) {
67300
- if (_config) {
67301
- return _config;
67302
- }
67303
- if (pendingConfigPromise) {
67304
- return await pendingConfigPromise;
67301
+ if (!forceReload) {
67302
+ if (_config) {
67303
+ return _config;
67304
+ }
67305
+ if (pendingConfigPromise) {
67306
+ return await pendingConfigPromise;
67307
+ }
67305
67308
  }
67306
67309
  let resolve2 = () => {
67307
67310
  };
@@ -67497,7 +67500,7 @@ async function loadSchemaFile(schemaPath) {
67497
67500
 
67498
67501
  // src/lib/graphql.ts
67499
67502
  var graphql3 = __toESM(require_graphql2(), 1);
67500
- import crypto from "crypto";
67503
+ import crypto from "node:crypto";
67501
67504
  function getRootType(type) {
67502
67505
  if (graphql3.isNonNullType(type)) {
67503
67506
  return getRootType(type.ofType);
@@ -70458,11 +70461,13 @@ function scalarPropertyValue(config4, missingScalars, target) {
70458
70461
 
70459
70462
  // src/codegen/generators/typescript/typeReference.ts
70460
70463
  var AST8 = recast8.types.builders;
70461
- function tsTypeReference(config4, missingScalars, definition) {
70464
+ function tsTypeReference(config4, missingScalars, definition, body) {
70462
70465
  const { type, wrappers } = unwrapType(config4, definition.type);
70463
70466
  let result;
70464
70467
  if (graphql16.isScalarType(type)) {
70465
70468
  result = scalarPropertyValue(config4, missingScalars, type);
70469
+ } else if (graphql16.isEnumType(type)) {
70470
+ result = enumReference(config4, body, type.name);
70466
70471
  } else {
70467
70472
  result = AST8.tsTypeReference(AST8.identifier(type.name));
70468
70473
  }
@@ -70477,6 +70482,19 @@ function tsTypeReference(config4, missingScalars, definition) {
70477
70482
  }
70478
70483
  return result;
70479
70484
  }
70485
+ function enumReference(config4, body, name) {
70486
+ ensureImports({
70487
+ config: config4,
70488
+ body,
70489
+ import: ["ValueOf"],
70490
+ importKind: "type",
70491
+ sourceModule: "$houdini/runtime/lib/types"
70492
+ });
70493
+ return AST8.tsTypeReference(
70494
+ AST8.identifier("ValueOf"),
70495
+ AST8.tsTypeParameterInstantiation([AST8.tsTypeQuery(AST8.identifier(name))])
70496
+ );
70497
+ }
70480
70498
 
70481
70499
  // src/codegen/generators/typescript/addReferencedInputTypes.ts
70482
70500
  var AST9 = recast9.types.builders;
@@ -70508,7 +70526,7 @@ function addReferencedInputTypes(config4, filepath, body, visitedTypes, missingS
70508
70526
  members.push(
70509
70527
  AST9.tsPropertySignature(
70510
70528
  AST9.identifier(field.name),
70511
- AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field)),
70529
+ AST9.tsTypeAnnotation(tsTypeReference(config4, missingScalars, field, body)),
70512
70530
  graphql17.isNullableType(field.type)
70513
70531
  )
70514
70532
  );
@@ -70539,6 +70557,13 @@ function inlineType({
70539
70557
  if (graphql18.isScalarType(type)) {
70540
70558
  result = scalarPropertyValue(config4, missingScalars, type);
70541
70559
  } else if (graphql18.isEnumType(type)) {
70560
+ ensureImports({
70561
+ config: config4,
70562
+ body,
70563
+ importKind: "type",
70564
+ import: ["ValueOf"],
70565
+ sourceModule: "$houdini/runtime/lib/types"
70566
+ });
70542
70567
  if (!visitedTypes.has(type.name)) {
70543
70568
  ensureImports({
70544
70569
  config: config4,
@@ -70548,7 +70573,7 @@ function inlineType({
70548
70573
  });
70549
70574
  visitedTypes.add(type.name);
70550
70575
  }
70551
- result = AST10.tsTypeReference(AST10.identifier(type.name));
70576
+ result = enumReference(config4, body, type.name);
70552
70577
  } else if (selections) {
70553
70578
  const rootObj = type;
70554
70579
  const inlineFragments = {};
@@ -70981,7 +71006,7 @@ async function generateOperationTypeDefs(config4, filepath, body, definition, se
70981
71006
  return AST11.tsPropertySignature(
70982
71007
  AST11.identifier(definition2.variable.name.value),
70983
71008
  AST11.tsTypeAnnotation(
70984
- tsTypeReference(config4, missingScalars, definition2)
71009
+ tsTypeReference(config4, missingScalars, definition2, body)
70985
71010
  ),
70986
71011
  definition2.type.kind !== "NonNullType"
70987
71012
  );
@@ -71048,7 +71073,12 @@ async function generateFragmentTypeDefs(config4, filepath, body, selections, def
71048
71073
  return AST11.tsPropertySignature(
71049
71074
  AST11.identifier(definition2.variable.name.value),
71050
71075
  AST11.tsTypeAnnotation(
71051
- tsTypeReference(config4, missingScalars, definition2)
71076
+ tsTypeReference(
71077
+ config4,
71078
+ missingScalars,
71079
+ definition2,
71080
+ body
71081
+ )
71052
71082
  ),
71053
71083
  definition2.type.kind !== "NonNullType"
71054
71084
  );
@@ -71141,7 +71171,7 @@ async function imperativeCacheTypef(config4, docs) {
71141
71171
  ),
71142
71172
  AST12.tsPropertySignature(
71143
71173
  AST12.identifier("lists"),
71144
- AST12.tsTypeAnnotation(listDefinitions(config4, docs))
71174
+ AST12.tsTypeAnnotation(listDefinitions(config4, body, docs))
71145
71175
  ),
71146
71176
  AST12.tsPropertySignature(
71147
71177
  AST12.identifier("queries"),
@@ -71250,7 +71280,7 @@ function typeDefinitions(config4, body, docs, returnType) {
71250
71280
  const prop = AST12.tsPropertySignature(
71251
71281
  AST12.identifier(arg.name),
71252
71282
  AST12.tsTypeAnnotation(
71253
- tsTypeReference(config4, /* @__PURE__ */ new Set(), arg)
71283
+ tsTypeReference(config4, /* @__PURE__ */ new Set(), arg, body)
71254
71284
  )
71255
71285
  );
71256
71286
  const unwrapped2 = unwrapType(config4, arg.type);
@@ -71300,7 +71330,7 @@ function typeDefinitions(config4, body, docs, returnType) {
71300
71330
  })
71301
71331
  );
71302
71332
  }
71303
- function listDefinitions(config4, docs) {
71333
+ function listDefinitions(config4, body, docs) {
71304
71334
  const lists = [];
71305
71335
  const visitedLists = /* @__PURE__ */ new Set();
71306
71336
  for (const doc of docs) {
@@ -71357,7 +71387,8 @@ function listDefinitions(config4, docs) {
71357
71387
  tsTypeReference(
71358
71388
  config4,
71359
71389
  /* @__PURE__ */ new Set(),
71360
- arg
71390
+ arg,
71391
+ body
71361
71392
  )
71362
71393
  )
71363
71394
  );
@@ -71551,9 +71582,9 @@ async function definitionsGenerator(config4) {
71551
71582
  ).code;
71552
71583
  const typeDefinitions2 = enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map(
71553
71584
  (definition) => `
71554
- export declare enum ${definition.name.value} {
71555
- ${definition.values?.map((value) => ` ${value.name.value} = "${value.name.value}"`).join(",\n")}
71556
- }
71585
+ export const ${definition.name.value} = {
71586
+ ${definition.values?.map((value) => ` ${value.name.value}: "${value.name.value}"`).join(",\n")}
71587
+ } as const
71557
71588
  `
71558
71589
  ).join("");
71559
71590
  const definitionsIndex = `
@@ -73169,9 +73200,10 @@ function vite_default(opts) {
73169
73200
  name: "Houdini",
73170
73201
  quiet: true,
73171
73202
  async watchFile(filepath) {
73172
- const config4 = await getConfig(opts);
73203
+ let config4 = await getConfig(opts);
73173
73204
  const schemaPath = path_exports.join(path_exports.dirname(config4.filepath), config4.schemaPath);
73174
73205
  if ((0, import_minimatch2.default)(filepath, schemaPath)) {
73206
+ config4 = await getConfig({ ...opts, forceReload: true });
73175
73207
  return true;
73176
73208
  }
73177
73209
  return config4.includeFile(filepath, { root: process.cwd() });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.0.0-next.7",
3
+ "version": "1.0.0-next.9",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",
@@ -16,15 +16,15 @@
16
16
  "license": "MIT",
17
17
  "type": "module",
18
18
  "devDependencies": {
19
- "@trivago/prettier-plugin-sort-imports": "^3.3.0",
19
+ "@trivago/prettier-plugin-sort-imports": "^4.0.0",
20
20
  "@types/glob": "^8.0.0",
21
21
  "@types/minimatch": "^5.1.2",
22
22
  "@types/node": "^18.7.23",
23
- "prettier": "^2.5.1",
23
+ "prettier": "^2.8.3",
24
24
  "rollup": "^3.7.4",
25
25
  "turbo": "^1.5.4",
26
26
  "vite": "^4.0.4",
27
- "vitest": "^0.23.4",
27
+ "vitest": "^0.28.3",
28
28
  "scripts": "^1.0.0"
29
29
  },
30
30
  "dependencies": {