houdini 1.2.6 → 1.2.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.
Files changed (34) hide show
  1. package/build/cmd-cjs/index.js +104 -66
  2. package/build/cmd-esm/index.js +104 -66
  3. package/build/codegen/generators/artifacts/index.d.ts +2 -0
  4. package/build/codegen-cjs/index.js +95 -61
  5. package/build/codegen-esm/index.js +95 -61
  6. package/build/lib/config.d.ts +1 -1
  7. package/build/lib/graphql.d.ts +5 -3
  8. package/build/lib-cjs/index.js +42 -23
  9. package/build/lib-esm/index.js +40 -22
  10. package/build/runtime/client/documentStore.d.ts +1 -0
  11. package/build/runtime/client/plugins/subscription.d.ts +3 -2
  12. package/build/runtime/lib/config.d.ts +4 -0
  13. package/build/runtime/public/types.d.ts +22 -4
  14. package/build/runtime-cjs/client/documentStore.d.ts +1 -0
  15. package/build/runtime-cjs/client/documentStore.js +1 -0
  16. package/build/runtime-cjs/client/plugins/fetch.js +14 -5
  17. package/build/runtime-cjs/client/plugins/fetchParams.js +2 -2
  18. package/build/runtime-cjs/client/plugins/subscription.d.ts +3 -2
  19. package/build/runtime-cjs/client/plugins/subscription.js +3 -3
  20. package/build/runtime-cjs/lib/config.d.ts +4 -0
  21. package/build/runtime-cjs/public/types.d.ts +22 -4
  22. package/build/runtime-esm/client/documentStore.d.ts +1 -0
  23. package/build/runtime-esm/client/documentStore.js +1 -0
  24. package/build/runtime-esm/client/plugins/fetch.js +14 -5
  25. package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
  26. package/build/runtime-esm/client/plugins/subscription.d.ts +3 -2
  27. package/build/runtime-esm/client/plugins/subscription.js +3 -3
  28. package/build/runtime-esm/lib/config.d.ts +4 -0
  29. package/build/runtime-esm/public/types.d.ts +22 -4
  30. package/build/test-cjs/index.js +101 -63
  31. package/build/test-esm/index.js +101 -63
  32. package/build/vite-cjs/index.js +101 -63
  33. package/build/vite-esm/index.js +101 -63
  34. package/package.json +1 -1
@@ -72473,7 +72473,7 @@ var Config = class {
72473
72473
  projectRoot;
72474
72474
  schema;
72475
72475
  schemaPath;
72476
- persistedQueryPath;
72476
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
72477
72477
  exclude;
72478
72478
  scalars;
72479
72479
  module = "esm";
@@ -72525,7 +72525,8 @@ var Config = class {
72525
72525
  logLevel,
72526
72526
  defaultFragmentMasking = "enable",
72527
72527
  watchSchema,
72528
- projectDir
72528
+ projectDir,
72529
+ persistedQueriesPath
72529
72530
  } = this.configFile;
72530
72531
  if (typeof schema === "string") {
72531
72532
  this.schema = graphql2.buildSchema(schema);
@@ -72562,6 +72563,9 @@ var Config = class {
72562
72563
  this.schemaPollHeaders = watchSchema?.headers ?? {};
72563
72564
  this.rootDir = join2(this.projectRoot, "$houdini");
72564
72565
  this.#fragmentVariableMaps = {};
72566
+ if (persistedQueriesPath) {
72567
+ this.persistedQueriesPath = persistedQueriesPath;
72568
+ }
72565
72569
  if (defaultKeys) {
72566
72570
  this.defaultKeys = defaultKeys;
72567
72571
  }
@@ -73276,11 +73280,14 @@ function getRootType(type) {
73276
73280
  }
73277
73281
  return type;
73278
73282
  }
73279
- function hashDocument({
73280
- document
73281
- }) {
73282
- const docString = typeof document === "string" ? document : document.originalString;
73283
- return import_node_crypto.default.createHash("sha256").update(docString ?? "").digest("hex");
73283
+ function hashOriginal({ document }) {
73284
+ return hashDocument(document.originalString);
73285
+ }
73286
+ function hashRaw({ document }) {
73287
+ return hashDocument(document.artifact?.raw);
73288
+ }
73289
+ function hashDocument(str) {
73290
+ return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
73284
73291
  }
73285
73292
  function parentField(ancestors) {
73286
73293
  return walkParentField([...ancestors].sort(() => -1));
@@ -74424,6 +74431,42 @@ function inlineFragmentArgs({
74424
74431
  filepath,
74425
74432
  document
74426
74433
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
74434
+ const modifyValue = (node) => {
74435
+ if (node.kind == "ObjectValue") {
74436
+ return {
74437
+ ...node,
74438
+ fields: node.fields.map((field) => {
74439
+ const modifiedValue = modifyValue(field.value);
74440
+ if (!modifiedValue)
74441
+ return null;
74442
+ return {
74443
+ ...field,
74444
+ value: modifyValue(field.value)
74445
+ };
74446
+ })
74447
+ };
74448
+ }
74449
+ if (node.kind !== "Variable") {
74450
+ return node;
74451
+ }
74452
+ if (!scope) {
74453
+ throw new HoudiniError({
74454
+ filepath,
74455
+ message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
74456
+ });
74457
+ }
74458
+ const newValue = scope[node.name.value];
74459
+ if (newValue) {
74460
+ return newValue;
74461
+ }
74462
+ if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
74463
+ throw new HoudiniError({
74464
+ filepath,
74465
+ message: "Missing value for required arg: " + node.name.value
74466
+ });
74467
+ }
74468
+ return null;
74469
+ };
74427
74470
  const result = esm_default(
74428
74471
  graphql5.visit(document, {
74429
74472
  FragmentSpread(node) {
@@ -74497,29 +74540,14 @@ function inlineFragmentArgs({
74497
74540
  }
74498
74541
  },
74499
74542
  Argument(node) {
74500
- const value = node.value;
74501
- if (value.kind !== "Variable") {
74502
- return;
74503
- }
74504
- if (!scope) {
74505
- throw new HoudiniError({
74506
- filepath,
74507
- message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
74508
- });
74509
- }
74510
- const newValue = scope[value.name.value];
74543
+ let value = node.value;
74544
+ const newValue = modifyValue(value);
74511
74545
  if (newValue) {
74512
74546
  return {
74513
74547
  ...node,
74514
74548
  value: newValue
74515
74549
  };
74516
74550
  }
74517
- if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
74518
- throw new HoudiniError({
74519
- filepath,
74520
- message: "Missing value for required arg: " + value.name.value
74521
- });
74522
- }
74523
74551
  return null;
74524
74552
  }
74525
74553
  })
@@ -76343,13 +76371,13 @@ function artifactGenerator(stats) {
76343
76371
  });
76344
76372
  }
76345
76373
  const listOfArtifacts = [];
76346
- const hash = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashDocument;
76374
+ const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
76347
76375
  await Promise.all(
76348
76376
  [
76349
76377
  writeIndexFile(config2, docs)
76350
76378
  ].concat(
76351
76379
  docs.map(async (doc) => {
76352
- const { document, name, generateArtifact, originalParsed, originalString } = doc;
76380
+ const { document, name, generateArtifact, originalParsed } = doc;
76353
76381
  if (!generateArtifact) {
76354
76382
  return;
76355
76383
  }
@@ -76456,7 +76484,7 @@ function artifactGenerator(stats) {
76456
76484
  let artifact = {
76457
76485
  name,
76458
76486
  kind: docKind,
76459
- hash: hash({ config: config2, document: doc }),
76487
+ hash: "NOT_YET",
76460
76488
  refetch: doc.refetch,
76461
76489
  raw: rawString,
76462
76490
  rootType,
@@ -76483,6 +76511,8 @@ function artifactGenerator(stats) {
76483
76511
  }),
76484
76512
  pluginData: {}
76485
76513
  };
76514
+ const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
76515
+ artifact.hash = hash_value;
76486
76516
  applyMask(
76487
76517
  config2,
76488
76518
  artifact.selection,
@@ -76557,11 +76587,10 @@ function artifactGenerator(stats) {
76557
76587
  }
76558
76588
  plugin2.artifactEnd({ config: config2, document: doc });
76559
76589
  }
76590
+ const _houdiniHash = hashOriginal({ document: doc });
76560
76591
  const file = AST5.program([
76561
76592
  moduleExport(config2, "default", serializeValue(artifact)),
76562
- AST5.expressionStatement(
76563
- AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
76564
- )
76593
+ AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
76565
76594
  ]);
76566
76595
  const artifactPath = config2.artifactPath(document);
76567
76596
  const countDocument = doc.generateStore;
@@ -76578,10 +76607,12 @@ function artifactGenerator(stats) {
76578
76607
  return;
76579
76608
  }
76580
76609
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
76581
- if (match && match[1] !== artifact.hash) {
76610
+ if (match && match[1] !== _houdiniHash) {
76582
76611
  stats.changed.push(artifact.name);
76583
76612
  }
76584
76613
  stats.total.push(artifact.name);
76614
+ stats.hashSize.push(artifact.hash.length);
76615
+ stats.querySize.push(artifact.raw.length);
76585
76616
  })
76586
76617
  )
76587
76618
  );
@@ -78186,39 +78217,36 @@ async function typescriptGenerator(config2, docs) {
78186
78217
  // src/codegen/generators/persistedQueries/index.ts
78187
78218
  var graphql20 = __toESM(require_graphql2(), 1);
78188
78219
  async function persistOutputGenerator(config2, docs) {
78189
- if (typeof config2.persistedQueryPath !== "string" || config2.persistedQueryPath.length === 0)
78190
- return;
78191
- if (!config2.persistedQueryPath.endsWith(".json")) {
78192
- console.log("Can only write the queryMap to a json file");
78193
- return;
78220
+ if (!config2.persistedQueriesPath.endsWith(".json")) {
78221
+ throw new Error('Can write Persisted Queries only in a ".json" file.');
78194
78222
  }
78195
- const queryMap = docs.reduce(
78196
- (acc, { document, generateArtifact }) => {
78197
- if (!generateArtifact) {
78198
- return acc;
78199
- }
78200
- let rawString = graphql20.print(
78201
- graphql20.visit(document, {
78202
- Directive(node) {
78203
- if (config2.isInternalDirective(node.name.value)) {
78204
- return null;
78205
- }
78223
+ const queryMap = docs.reduce((acc, doc) => {
78224
+ const { document, generateArtifact, artifact } = doc;
78225
+ if (!generateArtifact) {
78226
+ return acc;
78227
+ }
78228
+ let rawString = graphql20.print(
78229
+ graphql20.visit(document, {
78230
+ Directive(node) {
78231
+ if (config2.isInternalDirective(node.name.value)) {
78232
+ return null;
78206
78233
  }
78207
- })
78208
- );
78209
- const operations = document.definitions.filter(
78210
- ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
78211
- );
78212
- if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
78213
- acc[hashDocument({ config: config2, document: rawString })] = rawString;
78234
+ }
78235
+ })
78236
+ );
78237
+ const operations = document.definitions.filter(
78238
+ ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
78239
+ );
78240
+ if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
78241
+ if (artifact) {
78242
+ acc[artifact.hash] = rawString;
78214
78243
  }
78215
- return acc;
78216
- },
78217
- {}
78218
- );
78244
+ }
78245
+ return acc;
78246
+ }, {});
78219
78247
  if (Object.keys(queryMap).length === 0)
78220
78248
  return;
78221
- await fs_exports.writeFile(config2.persistedQueryPath, JSON.stringify(queryMap, null, 4));
78249
+ await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
78222
78250
  }
78223
78251
 
78224
78252
  // src/codegen/generators/definitions/enums.ts
@@ -79540,7 +79568,9 @@ async function runPipeline2(config2, docs) {
79540
79568
  total: [],
79541
79569
  changed: [],
79542
79570
  new: [],
79543
- deleted: []
79571
+ deleted: [],
79572
+ hashSize: [],
79573
+ querySize: []
79544
79574
  };
79545
79575
  const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
79546
79576
  const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
@@ -79553,6 +79583,9 @@ async function runPipeline2(config2, docs) {
79553
79583
  documents: docs2
79554
79584
  })
79555
79585
  );
79586
+ if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
79587
+ console.log("\u{1F3A9} Generating runtime...");
79588
+ }
79556
79589
  let error = null;
79557
79590
  try {
79558
79591
  await runPipeline(
@@ -79599,9 +79632,6 @@ async function runPipeline2(config2, docs) {
79599
79632
  }
79600
79633
  return;
79601
79634
  }
79602
- if (!config2.pluginMode) {
79603
- console.log("\u{1F3A9} Generating runtime...");
79604
- }
79605
79635
  if (error) {
79606
79636
  throw error;
79607
79637
  }
@@ -79626,6 +79656,14 @@ async function runPipeline2(config2, docs) {
79626
79656
  }
79627
79657
  console.log(`${emoji} ${artifact}`);
79628
79658
  }
79659
+ console.log(``);
79660
+ console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
79661
+ const format = (val) => {
79662
+ return `${(val / 1024).toFixed(1)} kb`;
79663
+ };
79664
+ const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
79665
+ const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
79666
+ console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
79629
79667
  }
79630
79668
  }
79631
79669
  async function collectDocuments(config2) {
@@ -79838,7 +79876,7 @@ async function generate(args = {
79838
79876
  try {
79839
79877
  config2 = await getConfig(extraConfig);
79840
79878
  if (args.output) {
79841
- config2.persistedQueryPath = args.output;
79879
+ config2.persistedQueriesPath = args.output;
79842
79880
  }
79843
79881
  if (args.pullSchema && await config2.apiURL()) {
79844
79882
  await pullSchema_default(args);
@@ -80227,8 +80265,8 @@ async function updatePackageJSON(targetPath) {
80227
80265
  }
80228
80266
  packageJSON.devDependencies = {
80229
80267
  ...packageJSON.devDependencies,
80230
- houdini: "^1.2.6",
80231
- "houdini-svelte": "^1.2.6"
80268
+ houdini: "^1.2.8",
80269
+ "houdini-svelte": "^1.2.8"
80232
80270
  };
80233
80271
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
80234
80272
  }
@@ -72478,7 +72478,7 @@ var Config = class {
72478
72478
  projectRoot;
72479
72479
  schema;
72480
72480
  schemaPath;
72481
- persistedQueryPath;
72481
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
72482
72482
  exclude;
72483
72483
  scalars;
72484
72484
  module = "esm";
@@ -72530,7 +72530,8 @@ var Config = class {
72530
72530
  logLevel,
72531
72531
  defaultFragmentMasking = "enable",
72532
72532
  watchSchema,
72533
- projectDir
72533
+ projectDir,
72534
+ persistedQueriesPath
72534
72535
  } = this.configFile;
72535
72536
  if (typeof schema === "string") {
72536
72537
  this.schema = graphql2.buildSchema(schema);
@@ -72567,6 +72568,9 @@ var Config = class {
72567
72568
  this.schemaPollHeaders = watchSchema?.headers ?? {};
72568
72569
  this.rootDir = join2(this.projectRoot, "$houdini");
72569
72570
  this.#fragmentVariableMaps = {};
72571
+ if (persistedQueriesPath) {
72572
+ this.persistedQueriesPath = persistedQueriesPath;
72573
+ }
72570
72574
  if (defaultKeys) {
72571
72575
  this.defaultKeys = defaultKeys;
72572
72576
  }
@@ -73281,11 +73285,14 @@ function getRootType(type) {
73281
73285
  }
73282
73286
  return type;
73283
73287
  }
73284
- function hashDocument({
73285
- document
73286
- }) {
73287
- const docString = typeof document === "string" ? document : document.originalString;
73288
- return crypto.createHash("sha256").update(docString ?? "").digest("hex");
73288
+ function hashOriginal({ document }) {
73289
+ return hashDocument(document.originalString);
73290
+ }
73291
+ function hashRaw({ document }) {
73292
+ return hashDocument(document.artifact?.raw);
73293
+ }
73294
+ function hashDocument(str) {
73295
+ return crypto.createHash("sha256").update(str || "").digest("hex");
73289
73296
  }
73290
73297
  function parentField(ancestors) {
73291
73298
  return walkParentField([...ancestors].sort(() => -1));
@@ -74429,6 +74436,42 @@ function inlineFragmentArgs({
74429
74436
  filepath,
74430
74437
  document
74431
74438
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
74439
+ const modifyValue = (node) => {
74440
+ if (node.kind == "ObjectValue") {
74441
+ return {
74442
+ ...node,
74443
+ fields: node.fields.map((field) => {
74444
+ const modifiedValue = modifyValue(field.value);
74445
+ if (!modifiedValue)
74446
+ return null;
74447
+ return {
74448
+ ...field,
74449
+ value: modifyValue(field.value)
74450
+ };
74451
+ })
74452
+ };
74453
+ }
74454
+ if (node.kind !== "Variable") {
74455
+ return node;
74456
+ }
74457
+ if (!scope) {
74458
+ throw new HoudiniError({
74459
+ filepath,
74460
+ message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
74461
+ });
74462
+ }
74463
+ const newValue = scope[node.name.value];
74464
+ if (newValue) {
74465
+ return newValue;
74466
+ }
74467
+ if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
74468
+ throw new HoudiniError({
74469
+ filepath,
74470
+ message: "Missing value for required arg: " + node.name.value
74471
+ });
74472
+ }
74473
+ return null;
74474
+ };
74432
74475
  const result = esm_default(
74433
74476
  graphql5.visit(document, {
74434
74477
  FragmentSpread(node) {
@@ -74502,29 +74545,14 @@ function inlineFragmentArgs({
74502
74545
  }
74503
74546
  },
74504
74547
  Argument(node) {
74505
- const value = node.value;
74506
- if (value.kind !== "Variable") {
74507
- return;
74508
- }
74509
- if (!scope) {
74510
- throw new HoudiniError({
74511
- filepath,
74512
- message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
74513
- });
74514
- }
74515
- const newValue = scope[value.name.value];
74548
+ let value = node.value;
74549
+ const newValue = modifyValue(value);
74516
74550
  if (newValue) {
74517
74551
  return {
74518
74552
  ...node,
74519
74553
  value: newValue
74520
74554
  };
74521
74555
  }
74522
- if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
74523
- throw new HoudiniError({
74524
- filepath,
74525
- message: "Missing value for required arg: " + value.name.value
74526
- });
74527
- }
74528
74556
  return null;
74529
74557
  }
74530
74558
  })
@@ -76348,13 +76376,13 @@ function artifactGenerator(stats) {
76348
76376
  });
76349
76377
  }
76350
76378
  const listOfArtifacts = [];
76351
- const hash = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashDocument;
76379
+ const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
76352
76380
  await Promise.all(
76353
76381
  [
76354
76382
  writeIndexFile(config2, docs)
76355
76383
  ].concat(
76356
76384
  docs.map(async (doc) => {
76357
- const { document, name, generateArtifact, originalParsed, originalString } = doc;
76385
+ const { document, name, generateArtifact, originalParsed } = doc;
76358
76386
  if (!generateArtifact) {
76359
76387
  return;
76360
76388
  }
@@ -76461,7 +76489,7 @@ function artifactGenerator(stats) {
76461
76489
  let artifact = {
76462
76490
  name,
76463
76491
  kind: docKind,
76464
- hash: hash({ config: config2, document: doc }),
76492
+ hash: "NOT_YET",
76465
76493
  refetch: doc.refetch,
76466
76494
  raw: rawString,
76467
76495
  rootType,
@@ -76488,6 +76516,8 @@ function artifactGenerator(stats) {
76488
76516
  }),
76489
76517
  pluginData: {}
76490
76518
  };
76519
+ const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
76520
+ artifact.hash = hash_value;
76491
76521
  applyMask(
76492
76522
  config2,
76493
76523
  artifact.selection,
@@ -76562,11 +76592,10 @@ function artifactGenerator(stats) {
76562
76592
  }
76563
76593
  plugin2.artifactEnd({ config: config2, document: doc });
76564
76594
  }
76595
+ const _houdiniHash = hashOriginal({ document: doc });
76565
76596
  const file = AST5.program([
76566
76597
  moduleExport(config2, "default", serializeValue(artifact)),
76567
- AST5.expressionStatement(
76568
- AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
76569
- )
76598
+ AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
76570
76599
  ]);
76571
76600
  const artifactPath = config2.artifactPath(document);
76572
76601
  const countDocument = doc.generateStore;
@@ -76583,10 +76612,12 @@ function artifactGenerator(stats) {
76583
76612
  return;
76584
76613
  }
76585
76614
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
76586
- if (match && match[1] !== artifact.hash) {
76615
+ if (match && match[1] !== _houdiniHash) {
76587
76616
  stats.changed.push(artifact.name);
76588
76617
  }
76589
76618
  stats.total.push(artifact.name);
76619
+ stats.hashSize.push(artifact.hash.length);
76620
+ stats.querySize.push(artifact.raw.length);
76590
76621
  })
76591
76622
  )
76592
76623
  );
@@ -78191,39 +78222,36 @@ async function typescriptGenerator(config2, docs) {
78191
78222
  // src/codegen/generators/persistedQueries/index.ts
78192
78223
  var graphql20 = __toESM(require_graphql2(), 1);
78193
78224
  async function persistOutputGenerator(config2, docs) {
78194
- if (typeof config2.persistedQueryPath !== "string" || config2.persistedQueryPath.length === 0)
78195
- return;
78196
- if (!config2.persistedQueryPath.endsWith(".json")) {
78197
- console.log("Can only write the queryMap to a json file");
78198
- return;
78225
+ if (!config2.persistedQueriesPath.endsWith(".json")) {
78226
+ throw new Error('Can write Persisted Queries only in a ".json" file.');
78199
78227
  }
78200
- const queryMap = docs.reduce(
78201
- (acc, { document, generateArtifact }) => {
78202
- if (!generateArtifact) {
78203
- return acc;
78204
- }
78205
- let rawString = graphql20.print(
78206
- graphql20.visit(document, {
78207
- Directive(node) {
78208
- if (config2.isInternalDirective(node.name.value)) {
78209
- return null;
78210
- }
78228
+ const queryMap = docs.reduce((acc, doc) => {
78229
+ const { document, generateArtifact, artifact } = doc;
78230
+ if (!generateArtifact) {
78231
+ return acc;
78232
+ }
78233
+ let rawString = graphql20.print(
78234
+ graphql20.visit(document, {
78235
+ Directive(node) {
78236
+ if (config2.isInternalDirective(node.name.value)) {
78237
+ return null;
78211
78238
  }
78212
- })
78213
- );
78214
- const operations = document.definitions.filter(
78215
- ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
78216
- );
78217
- if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
78218
- acc[hashDocument({ config: config2, document: rawString })] = rawString;
78239
+ }
78240
+ })
78241
+ );
78242
+ const operations = document.definitions.filter(
78243
+ ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
78244
+ );
78245
+ if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
78246
+ if (artifact) {
78247
+ acc[artifact.hash] = rawString;
78219
78248
  }
78220
- return acc;
78221
- },
78222
- {}
78223
- );
78249
+ }
78250
+ return acc;
78251
+ }, {});
78224
78252
  if (Object.keys(queryMap).length === 0)
78225
78253
  return;
78226
- await fs_exports.writeFile(config2.persistedQueryPath, JSON.stringify(queryMap, null, 4));
78254
+ await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
78227
78255
  }
78228
78256
 
78229
78257
  // src/codegen/generators/definitions/enums.ts
@@ -79545,7 +79573,9 @@ async function runPipeline2(config2, docs) {
79545
79573
  total: [],
79546
79574
  changed: [],
79547
79575
  new: [],
79548
- deleted: []
79576
+ deleted: [],
79577
+ hashSize: [],
79578
+ querySize: []
79549
79579
  };
79550
79580
  const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
79551
79581
  const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
@@ -79558,6 +79588,9 @@ async function runPipeline2(config2, docs) {
79558
79588
  documents: docs2
79559
79589
  })
79560
79590
  );
79591
+ if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
79592
+ console.log("\u{1F3A9} Generating runtime...");
79593
+ }
79561
79594
  let error = null;
79562
79595
  try {
79563
79596
  await runPipeline(
@@ -79604,9 +79637,6 @@ async function runPipeline2(config2, docs) {
79604
79637
  }
79605
79638
  return;
79606
79639
  }
79607
- if (!config2.pluginMode) {
79608
- console.log("\u{1F3A9} Generating runtime...");
79609
- }
79610
79640
  if (error) {
79611
79641
  throw error;
79612
79642
  }
@@ -79631,6 +79661,14 @@ async function runPipeline2(config2, docs) {
79631
79661
  }
79632
79662
  console.log(`${emoji} ${artifact}`);
79633
79663
  }
79664
+ console.log(``);
79665
+ console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
79666
+ const format = (val) => {
79667
+ return `${(val / 1024).toFixed(1)} kb`;
79668
+ };
79669
+ const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
79670
+ const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
79671
+ console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
79634
79672
  }
79635
79673
  }
79636
79674
  async function collectDocuments(config2) {
@@ -79843,7 +79881,7 @@ async function generate(args = {
79843
79881
  try {
79844
79882
  config2 = await getConfig(extraConfig);
79845
79883
  if (args.output) {
79846
- config2.persistedQueryPath = args.output;
79884
+ config2.persistedQueriesPath = args.output;
79847
79885
  }
79848
79886
  if (args.pullSchema && await config2.apiURL()) {
79849
79887
  await pullSchema_default(args);
@@ -80232,8 +80270,8 @@ async function updatePackageJSON(targetPath) {
80232
80270
  }
80233
80271
  packageJSON.devDependencies = {
80234
80272
  ...packageJSON.devDependencies,
80235
- houdini: "^1.2.6",
80236
- "houdini-svelte": "^1.2.6"
80273
+ houdini: "^1.2.8",
80274
+ "houdini-svelte": "^1.2.8"
80237
80275
  };
80238
80276
  await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
80239
80277
  }
@@ -4,4 +4,6 @@ export default function artifactGenerator(stats: {
4
4
  new: string[];
5
5
  changed: string[];
6
6
  deleted: string[];
7
+ hashSize: number[];
8
+ querySize: number[];
7
9
  }): (config: Config, docs: Document[]) => Promise<void>;