houdini 2.0.0-next.0 → 2.0.0-next.1

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.
@@ -72461,7 +72461,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
72461
72461
  }
72462
72462
 
72463
72463
  // src/lib/introspection.ts
72464
- async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
72464
+ async function pullSchema(url, fetchTimeout, schemaPath, headers, writeToDisk = true) {
72465
72465
  let content = "";
72466
72466
  try {
72467
72467
  const fetchWithTimeout = (url2, timeoutMs, options) => {
@@ -72499,8 +72499,15 @@ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
72499
72499
  } else {
72500
72500
  fileData = JSON.stringify(jsonSchema);
72501
72501
  }
72502
- if (!skipWriting) {
72503
- await writeFile(schemaPath, fileData);
72502
+ if (writeToDisk) {
72503
+ try {
72504
+ await writeFile(schemaPath, fileData);
72505
+ } catch (e2) {
72506
+ console.warn(
72507
+ `\u26A0\uFE0F Couldn't write your pulled schema to disk: ${e2.message}
72508
+ If this is expected, please set watchSchema.writePolledSchema to false in your config file.`
72509
+ );
72510
+ }
72504
72511
  }
72505
72512
  return fileData;
72506
72513
  } catch (e2) {
@@ -75726,6 +75733,7 @@ var Config = class {
75726
75733
  routesDir;
75727
75734
  schemaPollInterval;
75728
75735
  schemaPollTimeout;
75736
+ schemaPollWriteToDisk = false;
75729
75737
  schemaPollHeaders;
75730
75738
  pluginMode = false;
75731
75739
  plugins = [];
@@ -75802,6 +75810,7 @@ var Config = class {
75802
75810
  this.routesDir = join2(this.projectRoot, "src", "routes");
75803
75811
  this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
75804
75812
  this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
75813
+ this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
75805
75814
  this.schemaPollHeaders = watchSchema?.headers ?? {};
75806
75815
  this.rootDir = join2(this.projectRoot, this.runtimeDir);
75807
75816
  this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
@@ -75834,11 +75843,17 @@ var Config = class {
75834
75843
  const include = [`src/**/*{${extensions.join(",")}}`];
75835
75844
  for (const plugin2 of this.plugins) {
75836
75845
  const runtimeDir = this.pluginRuntimeSource(plugin2);
75837
- if (!runtimeDir) {
75846
+ const staticDir = this.pluginStaticRuntimeSource(plugin2);
75847
+ if (!runtimeDir && !staticDir) {
75838
75848
  continue;
75839
75849
  }
75840
- const includePath = relative(this.projectRoot, runtimeDir);
75841
- include.push(`${includePath}/**/*{${extensions.join(",")}}`);
75850
+ for (const dir of [runtimeDir, staticDir]) {
75851
+ if (!dir) {
75852
+ continue;
75853
+ }
75854
+ const includePath = relative(this.projectRoot, dir);
75855
+ include.push(`${includePath}/**/*{${extensions.join(",")}}`);
75856
+ }
75842
75857
  }
75843
75858
  return include;
75844
75859
  }
@@ -75892,6 +75907,15 @@ var Config = class {
75892
75907
  typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
75893
75908
  );
75894
75909
  }
75910
+ pluginStaticRuntimeSource(plugin2) {
75911
+ if (!plugin2.staticRuntime) {
75912
+ return null;
75913
+ }
75914
+ return join2(
75915
+ dirname(plugin2.filepath),
75916
+ typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
75917
+ );
75918
+ }
75895
75919
  async sourceFiles() {
75896
75920
  return [
75897
75921
  ...new Set(
@@ -76088,6 +76112,9 @@ var Config = class {
76088
76112
  pluginRuntimeDirectory(name) {
76089
76113
  return join2(this.pluginDirectory(name), "runtime");
76090
76114
  }
76115
+ pluginStaticRuntimeDirectory(name) {
76116
+ return join2(this.pluginDirectory(name), "static");
76117
+ }
76091
76118
  get pluginRootDirectory() {
76092
76119
  return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
76093
76120
  }
@@ -76465,17 +76492,20 @@ async function getConfig({
76465
76492
  if (!_config.localSchema && _config.schemaPath && !_config.schema) {
76466
76493
  let schemaOk = true;
76467
76494
  if (apiURL) {
76468
- if (glob2.hasMagic(_config.schemaPath)) {
76495
+ if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
76469
76496
  console.log(
76470
76497
  `\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
76471
- This will prevent your schema from being pulled.`
76498
+ This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
76472
76499
  );
76500
+ _config.schemaPollWriteToDisk = false;
76473
76501
  } else if (!await readFile(_config.schemaPath)) {
76474
76502
  console.log("\u231B Pulling schema from api");
76475
76503
  schemaOk = await pullSchema(
76476
76504
  apiURL,
76477
76505
  _config.schemaPollTimeout,
76478
- _config.schemaPath
76506
+ _config.schemaPath,
76507
+ {},
76508
+ _config.schemaPollWriteToDisk
76479
76509
  ) !== null;
76480
76510
  }
76481
76511
  }
@@ -79809,6 +79839,50 @@ function moduleStatments(config2) {
79809
79839
  exportStarStatement
79810
79840
  };
79811
79841
  }
79842
+ async function generateStaticRuntimes({ config: config2 }) {
79843
+ if (houdini_mode.is_testing) {
79844
+ return;
79845
+ }
79846
+ const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config2);
79847
+ await Promise.all(
79848
+ config2.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
79849
+ const runtime_path = config2.pluginStaticRuntimeSource(plugin2);
79850
+ if (!runtime_path) {
79851
+ return;
79852
+ }
79853
+ try {
79854
+ await stat(runtime_path);
79855
+ } catch {
79856
+ throw new HoudiniError({
79857
+ message: "Cannot find runtime to generate for " + plugin2.name,
79858
+ description: "Maybe it was bundled?"
79859
+ });
79860
+ }
79861
+ const pluginDir = config2.pluginStaticRuntimeDirectory(plugin2.name);
79862
+ let transformMap = plugin2.transformRuntime ?? {};
79863
+ if (transformMap && typeof transformMap === "function") {
79864
+ transformMap = transformMap([], { config: config2 });
79865
+ }
79866
+ await mkdirp(pluginDir);
79867
+ await recursiveCopy(
79868
+ runtime_path,
79869
+ pluginDir,
79870
+ Object.fromEntries(
79871
+ Object.entries(transformMap).map(([key, value]) => [
79872
+ join2(runtime_path, key),
79873
+ (content) => value({
79874
+ config: config2,
79875
+ content,
79876
+ importStatement,
79877
+ exportDefaultStatement,
79878
+ exportStarStatement
79879
+ })
79880
+ ])
79881
+ )
79882
+ );
79883
+ })
79884
+ );
79885
+ }
79812
79886
  async function generatePluginRuntimes({
79813
79887
  config: config2,
79814
79888
  docs
@@ -81410,6 +81484,11 @@ async function writeIndexFile2(config2, docs) {
81410
81484
  module: relative2(config2.pluginRuntimeDirectory(plugin2.name))
81411
81485
  });
81412
81486
  }
81487
+ if (plugin2.staticRuntime) {
81488
+ body += exportStar({
81489
+ module: relative2(config2.pluginStaticRuntimeDirectory(plugin2.name))
81490
+ });
81491
+ }
81413
81492
  }
81414
81493
  await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
81415
81494
  }
@@ -85327,6 +85406,7 @@ async function componentFields2(config2, docs) {
85327
85406
 
85328
85407
  // src/codegen/index.ts
85329
85408
  async function compile(config2) {
85409
+ await generateStaticRuntimes({ config: config2 });
85330
85410
  const documents = await collectDocuments(config2);
85331
85411
  return await runPipeline2(config2, documents);
85332
85412
  }
@@ -85938,7 +86018,8 @@ function watch_remote_schema(opts = {}) {
85938
86018
  apiURL,
85939
86019
  config2.schemaPollTimeout,
85940
86020
  config2.schemaPath ?? path_exports.resolve(process.cwd(), "schema.json"),
85941
- await config2.pullHeaders()
86021
+ await config2.pullHeaders(),
86022
+ config2.schemaPollWriteToDisk
85942
86023
  );
85943
86024
  nbPullError = schemaState ? 0 : nbPullError + 1;
85944
86025
  } catch (e2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "2.0.0-next.0",
3
+ "version": "2.0.0-next.1",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",