houdini-svelte 1.2.6 → 1.2.7

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.
@@ -84573,11 +84573,11 @@ var require_esprima2 = __commonJS2({
84573
84573
  case "}":
84574
84574
  regex2 = false;
84575
84575
  if (this.values[this.curly - 3] === "function") {
84576
- var check2 = this.values[this.curly - 4];
84577
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84576
+ var check = this.values[this.curly - 4];
84577
+ regex2 = check ? !this.beforeFunctionExpression(check) : false;
84578
84578
  } else if (this.values[this.curly - 4] === "function") {
84579
- var check2 = this.values[this.curly - 5];
84580
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84579
+ var check = this.values[this.curly - 5];
84580
+ regex2 = check ? !this.beforeFunctionExpression(check) : true;
84581
84581
  }
84582
84582
  break;
84583
84583
  default:
@@ -188549,7 +188549,7 @@ export const redirect = svelteKitRedirect
188549
188549
  schema({ config: config4 }) {
188550
188550
  return `
188551
188551
  """
188552
- @${config4.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
188552
+ @${config4.loadDirective} is used to enable automatic fetch on inline queries.
188553
188553
  """
188554
188554
  directive @${config4.loadDirective} on QUERY
188555
188555
 
@@ -84564,11 +84564,11 @@ var require_esprima2 = __commonJS2({
84564
84564
  case "}":
84565
84565
  regex2 = false;
84566
84566
  if (this.values[this.curly - 3] === "function") {
84567
- var check2 = this.values[this.curly - 4];
84568
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84567
+ var check = this.values[this.curly - 4];
84568
+ regex2 = check ? !this.beforeFunctionExpression(check) : false;
84569
84569
  } else if (this.values[this.curly - 4] === "function") {
84570
- var check2 = this.values[this.curly - 5];
84571
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84570
+ var check = this.values[this.curly - 5];
84571
+ regex2 = check ? !this.beforeFunctionExpression(check) : true;
84572
84572
  }
84573
84573
  break;
84574
84574
  default:
@@ -188539,7 +188539,7 @@ export const redirect = svelteKitRedirect
188539
188539
  schema({ config: config4 }) {
188540
188540
  return `
188541
188541
  """
188542
- @${config4.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
188542
+ @${config4.loadDirective} is used to enable automatic fetch on inline queries.
188543
188543
  """
188544
188544
  directive @${config4.loadDirective} on QUERY
188545
188545
 
@@ -84577,11 +84577,11 @@ var require_esprima2 = __commonJS2({
84577
84577
  case "}":
84578
84578
  regex2 = false;
84579
84579
  if (this.values[this.curly - 3] === "function") {
84580
- var check2 = this.values[this.curly - 4];
84581
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84580
+ var check = this.values[this.curly - 4];
84581
+ regex2 = check ? !this.beforeFunctionExpression(check) : false;
84582
84582
  } else if (this.values[this.curly - 4] === "function") {
84583
- var check2 = this.values[this.curly - 5];
84584
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84583
+ var check = this.values[this.curly - 5];
84584
+ regex2 = check ? !this.beforeFunctionExpression(check) : true;
84585
84585
  }
84586
84586
  break;
84587
84587
  default:
@@ -96024,7 +96024,7 @@ var Config = class {
96024
96024
  projectRoot;
96025
96025
  schema;
96026
96026
  schemaPath;
96027
- persistedQueryPath;
96027
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
96028
96028
  exclude;
96029
96029
  scalars;
96030
96030
  module = "esm";
@@ -96076,7 +96076,8 @@ var Config = class {
96076
96076
  logLevel,
96077
96077
  defaultFragmentMasking = "enable",
96078
96078
  watchSchema,
96079
- projectDir
96079
+ projectDir,
96080
+ persistedQueriesPath
96080
96081
  } = this.configFile;
96081
96082
  if (typeof schema === "string") {
96082
96083
  this.schema = graphql2.buildSchema(schema);
@@ -96113,6 +96114,9 @@ var Config = class {
96113
96114
  this.schemaPollHeaders = watchSchema?.headers ?? {};
96114
96115
  this.rootDir = join2(this.projectRoot, "$houdini");
96115
96116
  this.#fragmentVariableMaps = {};
96117
+ if (persistedQueriesPath) {
96118
+ this.persistedQueriesPath = persistedQueriesPath;
96119
+ }
96116
96120
  if (defaultKeys) {
96117
96121
  this.defaultKeys = defaultKeys;
96118
96122
  }
@@ -84570,11 +84570,11 @@ var require_esprima2 = __commonJS2({
84570
84570
  case "}":
84571
84571
  regex2 = false;
84572
84572
  if (this.values[this.curly - 3] === "function") {
84573
- var check2 = this.values[this.curly - 4];
84574
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84573
+ var check = this.values[this.curly - 4];
84574
+ regex2 = check ? !this.beforeFunctionExpression(check) : false;
84575
84575
  } else if (this.values[this.curly - 4] === "function") {
84576
- var check2 = this.values[this.curly - 5];
84577
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84576
+ var check = this.values[this.curly - 5];
84577
+ regex2 = check ? !this.beforeFunctionExpression(check) : true;
84578
84578
  }
84579
84579
  break;
84580
84580
  default:
@@ -96017,7 +96017,7 @@ var Config = class {
96017
96017
  projectRoot;
96018
96018
  schema;
96019
96019
  schemaPath;
96020
- persistedQueryPath;
96020
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
96021
96021
  exclude;
96022
96022
  scalars;
96023
96023
  module = "esm";
@@ -96069,7 +96069,8 @@ var Config = class {
96069
96069
  logLevel,
96070
96070
  defaultFragmentMasking = "enable",
96071
96071
  watchSchema,
96072
- projectDir
96072
+ projectDir,
96073
+ persistedQueriesPath
96073
96074
  } = this.configFile;
96074
96075
  if (typeof schema === "string") {
96075
96076
  this.schema = graphql2.buildSchema(schema);
@@ -96106,6 +96107,9 @@ var Config = class {
96106
96107
  this.schemaPollHeaders = watchSchema?.headers ?? {};
96107
96108
  this.rootDir = join2(this.projectRoot, "$houdini");
96108
96109
  this.#fragmentVariableMaps = {};
96110
+ if (persistedQueriesPath) {
96111
+ this.persistedQueriesPath = persistedQueriesPath;
96112
+ }
96109
96113
  if (defaultKeys) {
96110
96114
  this.defaultKeys = defaultKeys;
96111
96115
  }
@@ -84576,11 +84576,11 @@ var require_esprima2 = __commonJS2({
84576
84576
  case "}":
84577
84577
  regex2 = false;
84578
84578
  if (this.values[this.curly - 3] === "function") {
84579
- var check2 = this.values[this.curly - 4];
84580
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84579
+ var check = this.values[this.curly - 4];
84580
+ regex2 = check ? !this.beforeFunctionExpression(check) : false;
84581
84581
  } else if (this.values[this.curly - 4] === "function") {
84582
- var check2 = this.values[this.curly - 5];
84583
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84582
+ var check = this.values[this.curly - 5];
84583
+ regex2 = check ? !this.beforeFunctionExpression(check) : true;
84584
84584
  }
84585
84585
  break;
84586
84586
  default:
@@ -149458,11 +149458,14 @@ function getRootType(type) {
149458
149458
  }
149459
149459
  return type;
149460
149460
  }
149461
- function hashDocument({
149462
- document: document2
149463
- }) {
149464
- const docString = typeof document2 === "string" ? document2 : document2.originalString;
149465
- return import_node_crypto.default.createHash("sha256").update(docString ?? "").digest("hex");
149461
+ function hashOriginal({ document: document2 }) {
149462
+ return hashDocument(document2.originalString);
149463
+ }
149464
+ function hashRaw({ document: document2 }) {
149465
+ return hashDocument(document2.artifact?.raw);
149466
+ }
149467
+ function hashDocument(str) {
149468
+ return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
149466
149469
  }
149467
149470
  function parentField(ancestors) {
149468
149471
  return walkParentField([...ancestors].sort(() => -1));
@@ -150313,6 +150316,42 @@ function inlineFragmentArgs({
150313
150316
  filepath,
150314
150317
  document2
150315
150318
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
150319
+ const modifyValue = (node2) => {
150320
+ if (node2.kind == "ObjectValue") {
150321
+ return {
150322
+ ...node2,
150323
+ fields: node2.fields.map((field) => {
150324
+ const modifiedValue = modifyValue(field.value);
150325
+ if (!modifiedValue)
150326
+ return null;
150327
+ return {
150328
+ ...field,
150329
+ value: modifyValue(field.value)
150330
+ };
150331
+ })
150332
+ };
150333
+ }
150334
+ if (node2.kind !== "Variable") {
150335
+ return node2;
150336
+ }
150337
+ if (!scope2) {
150338
+ throw new HoudiniError2({
150339
+ filepath,
150340
+ message: node2.name.value + " is not defined in the current scope: " + JSON.stringify(scope2)
150341
+ });
150342
+ }
150343
+ const newValue = scope2[node2.name.value];
150344
+ if (newValue) {
150345
+ return newValue;
150346
+ }
150347
+ if (definitionArgs[node2.name.value] && definitionArgs[node2.name.value].required) {
150348
+ throw new HoudiniError2({
150349
+ filepath,
150350
+ message: "Missing value for required arg: " + node2.name.value
150351
+ });
150352
+ }
150353
+ return null;
150354
+ };
150316
150355
  const result = esm_default(
150317
150356
  graphql42.visit(document2, {
150318
150357
  FragmentSpread(node2) {
@@ -150386,29 +150425,14 @@ function inlineFragmentArgs({
150386
150425
  }
150387
150426
  },
150388
150427
  Argument(node2) {
150389
- const value2 = node2.value;
150390
- if (value2.kind !== "Variable") {
150391
- return;
150392
- }
150393
- if (!scope2) {
150394
- throw new HoudiniError2({
150395
- filepath,
150396
- message: node2.name.value + " is not defined in the current scope: " + JSON.stringify(scope2)
150397
- });
150398
- }
150399
- const newValue = scope2[value2.name.value];
150428
+ let value2 = node2.value;
150429
+ const newValue = modifyValue(value2);
150400
150430
  if (newValue) {
150401
150431
  return {
150402
150432
  ...node2,
150403
150433
  value: newValue
150404
150434
  };
150405
150435
  }
150406
- if (definitionArgs[value2.name.value] && definitionArgs[value2.name.value].required) {
150407
- throw new HoudiniError2({
150408
- filepath,
150409
- message: "Missing value for required arg: " + value2.name.value
150410
- });
150411
- }
150412
150436
  return null;
150413
150437
  }
150414
150438
  })
@@ -152204,13 +152228,13 @@ function artifactGenerator(stats) {
152204
152228
  });
152205
152229
  }
152206
152230
  const listOfArtifacts = [];
152207
- const hash = config22.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashDocument;
152231
+ const hashPluginBaseRaw = config22.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
152208
152232
  await Promise.all(
152209
152233
  [
152210
152234
  writeIndexFile(config22, docs)
152211
152235
  ].concat(
152212
152236
  docs.map(async (doc) => {
152213
- const { document: document2, name, generateArtifact, originalParsed, originalString } = doc;
152237
+ const { document: document2, name, generateArtifact, originalParsed } = doc;
152214
152238
  if (!generateArtifact) {
152215
152239
  return;
152216
152240
  }
@@ -152317,7 +152341,7 @@ function artifactGenerator(stats) {
152317
152341
  let artifact = {
152318
152342
  name,
152319
152343
  kind: docKind,
152320
- hash: hash({ config: config22, document: doc }),
152344
+ hash: "NOT_YET",
152321
152345
  refetch: doc.refetch,
152322
152346
  raw: rawString,
152323
152347
  rootType,
@@ -152344,6 +152368,8 @@ function artifactGenerator(stats) {
152344
152368
  }),
152345
152369
  pluginData: {}
152346
152370
  };
152371
+ const hash_value = hashPluginBaseRaw({ config: config22, document: { ...doc, artifact } });
152372
+ artifact.hash = hash_value;
152347
152373
  applyMask(
152348
152374
  config22,
152349
152375
  artifact.selection,
@@ -152418,11 +152444,10 @@ function artifactGenerator(stats) {
152418
152444
  }
152419
152445
  plugin2.artifactEnd({ config: config22, document: doc });
152420
152446
  }
152447
+ const _houdiniHash = hashOriginal({ document: doc });
152421
152448
  const file = AST5.program([
152422
152449
  moduleExport(config22, "default", serializeValue(artifact)),
152423
- AST5.expressionStatement(
152424
- AST5.stringLiteral(`HoudiniHash=${hash({ config: config22, document: doc })}`)
152425
- )
152450
+ AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
152426
152451
  ]);
152427
152452
  const artifactPath = config22.artifactPath(document2);
152428
152453
  const countDocument = doc.generateStore;
@@ -152439,10 +152464,12 @@ function artifactGenerator(stats) {
152439
152464
  return;
152440
152465
  }
152441
152466
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
152442
- if (match && match[1] !== artifact.hash) {
152467
+ if (match && match[1] !== _houdiniHash) {
152443
152468
  stats.changed.push(artifact.name);
152444
152469
  }
152445
152470
  stats.total.push(artifact.name);
152471
+ stats.hashSize.push(artifact.hash.length);
152472
+ stats.querySize.push(artifact.raw.length);
152446
152473
  })
152447
152474
  )
152448
152475
  );
@@ -154013,39 +154040,36 @@ async function typescriptGenerator(config22, docs) {
154013
154040
  }
154014
154041
  var graphql19 = __toESM3(require_graphql22(), 1);
154015
154042
  async function persistOutputGenerator(config22, docs) {
154016
- if (typeof config22.persistedQueryPath !== "string" || config22.persistedQueryPath.length === 0)
154017
- return;
154018
- if (!config22.persistedQueryPath.endsWith(".json")) {
154019
- console.log("Can only write the queryMap to a json file");
154020
- return;
154043
+ if (!config22.persistedQueriesPath.endsWith(".json")) {
154044
+ throw new Error('Can write Persisted Queries only in a ".json" file.');
154021
154045
  }
154022
- const queryMap = docs.reduce(
154023
- (acc, { document: document2, generateArtifact }) => {
154024
- if (!generateArtifact) {
154025
- return acc;
154026
- }
154027
- let rawString = graphql19.print(
154028
- graphql19.visit(document2, {
154029
- Directive(node2) {
154030
- if (config22.isInternalDirective(node2.name.value)) {
154031
- return null;
154032
- }
154046
+ const queryMap = docs.reduce((acc, doc) => {
154047
+ const { document: document2, generateArtifact, artifact } = doc;
154048
+ if (!generateArtifact) {
154049
+ return acc;
154050
+ }
154051
+ let rawString = graphql19.print(
154052
+ graphql19.visit(document2, {
154053
+ Directive(node2) {
154054
+ if (config22.isInternalDirective(node2.name.value)) {
154055
+ return null;
154033
154056
  }
154034
- })
154035
- );
154036
- const operations = document2.definitions.filter(
154037
- ({ kind }) => kind === graphql19.Kind.OPERATION_DEFINITION
154038
- );
154039
- if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
154040
- acc[hashDocument({ config: config22, document: rawString })] = rawString;
154057
+ }
154058
+ })
154059
+ );
154060
+ const operations = document2.definitions.filter(
154061
+ ({ kind }) => kind === graphql19.Kind.OPERATION_DEFINITION
154062
+ );
154063
+ if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
154064
+ if (artifact) {
154065
+ acc[artifact.hash] = rawString;
154041
154066
  }
154042
- return acc;
154043
- },
154044
- {}
154045
- );
154067
+ }
154068
+ return acc;
154069
+ }, {});
154046
154070
  if (Object.keys(queryMap).length === 0)
154047
154071
  return;
154048
- await fs_exports2.writeFile(config22.persistedQueryPath, JSON.stringify(queryMap, null, 4));
154072
+ await fs_exports2.writeFile(config22.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
154049
154073
  }
154050
154074
  var graphql20 = __toESM3(require_graphql22(), 1);
154051
154075
  var recast14 = __toESM3(require_main22(), 1);
@@ -155341,7 +155365,9 @@ async function runPipeline22(config22, docs) {
155341
155365
  total: [],
155342
155366
  changed: [],
155343
155367
  new: [],
155344
- deleted: []
155368
+ deleted: [],
155369
+ hashSize: [],
155370
+ querySize: []
155345
155371
  };
155346
155372
  const generatePlugins = config22.plugins.filter((plugin2) => plugin2.generate);
155347
155373
  const afterValidate = config22.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
@@ -155354,6 +155380,9 @@ async function runPipeline22(config22, docs) {
155354
155380
  documents: docs2
155355
155381
  })
155356
155382
  );
155383
+ if (!config22.pluginMode && process.env.HOUDINI_TEST !== "true") {
155384
+ console.log("\u{1F3A9} Generating runtime...");
155385
+ }
155357
155386
  let error2 = null;
155358
155387
  try {
155359
155388
  await runPipeline2(
@@ -155400,9 +155429,6 @@ async function runPipeline22(config22, docs) {
155400
155429
  }
155401
155430
  return;
155402
155431
  }
155403
- if (!config22.pluginMode) {
155404
- console.log("\u{1F3A9} Generating runtime...");
155405
- }
155406
155432
  if (error2) {
155407
155433
  throw error2;
155408
155434
  }
@@ -155427,6 +155453,14 @@ async function runPipeline22(config22, docs) {
155427
155453
  }
155428
155454
  console.log(`${emoji} ${artifact}`);
155429
155455
  }
155456
+ console.log(``);
155457
+ console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
155458
+ const format = (val) => {
155459
+ return `${(val / 1024).toFixed(1)} kb`;
155460
+ };
155461
+ const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
155462
+ const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
155463
+ console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
155430
155464
  }
155431
155465
  }
155432
155466
  function logStyled(kind, stat23, logLevel, plugin2) {
@@ -211853,7 +211887,7 @@ var Config = class {
211853
211887
  projectRoot;
211854
211888
  schema;
211855
211889
  schemaPath;
211856
- persistedQueryPath;
211890
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
211857
211891
  exclude;
211858
211892
  scalars;
211859
211893
  module = "esm";
@@ -211905,7 +211939,8 @@ var Config = class {
211905
211939
  logLevel,
211906
211940
  defaultFragmentMasking = "enable",
211907
211941
  watchSchema,
211908
- projectDir
211942
+ projectDir,
211943
+ persistedQueriesPath
211909
211944
  } = this.configFile;
211910
211945
  if (typeof schema2 === "string") {
211911
211946
  this.schema = graphql27.buildSchema(schema2);
@@ -211942,6 +211977,9 @@ var Config = class {
211942
211977
  this.schemaPollHeaders = watchSchema?.headers ?? {};
211943
211978
  this.rootDir = join4(this.projectRoot, "$houdini");
211944
211979
  this.#fragmentVariableMaps = {};
211980
+ if (persistedQueriesPath) {
211981
+ this.persistedQueriesPath = persistedQueriesPath;
211982
+ }
211945
211983
  if (defaultKeys) {
211946
211984
  this.defaultKeys = defaultKeys;
211947
211985
  }
@@ -308403,7 +308441,7 @@ export const redirect = svelteKitRedirect
308403
308441
  schema({ config: config5 }) {
308404
308442
  return `
308405
308443
  """
308406
- @${config5.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
308444
+ @${config5.loadDirective} is used to enable automatic fetch on inline queries.
308407
308445
  """
308408
308446
  directive @${config5.loadDirective} on QUERY
308409
308447
 
@@ -84564,11 +84564,11 @@ var require_esprima2 = __commonJS2({
84564
84564
  case "}":
84565
84565
  regex2 = false;
84566
84566
  if (this.values[this.curly - 3] === "function") {
84567
- var check2 = this.values[this.curly - 4];
84568
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : false;
84567
+ var check = this.values[this.curly - 4];
84568
+ regex2 = check ? !this.beforeFunctionExpression(check) : false;
84569
84569
  } else if (this.values[this.curly - 4] === "function") {
84570
- var check2 = this.values[this.curly - 5];
84571
- regex2 = check2 ? !this.beforeFunctionExpression(check2) : true;
84570
+ var check = this.values[this.curly - 5];
84571
+ regex2 = check ? !this.beforeFunctionExpression(check) : true;
84572
84572
  }
84573
84573
  break;
84574
84574
  default:
@@ -149445,11 +149445,14 @@ function getRootType(type) {
149445
149445
  }
149446
149446
  return type;
149447
149447
  }
149448
- function hashDocument({
149449
- document: document2
149450
- }) {
149451
- const docString = typeof document2 === "string" ? document2 : document2.originalString;
149452
- return crypto.createHash("sha256").update(docString ?? "").digest("hex");
149448
+ function hashOriginal({ document: document2 }) {
149449
+ return hashDocument(document2.originalString);
149450
+ }
149451
+ function hashRaw({ document: document2 }) {
149452
+ return hashDocument(document2.artifact?.raw);
149453
+ }
149454
+ function hashDocument(str) {
149455
+ return crypto.createHash("sha256").update(str || "").digest("hex");
149453
149456
  }
149454
149457
  function parentField(ancestors) {
149455
149458
  return walkParentField([...ancestors].sort(() => -1));
@@ -150300,6 +150303,42 @@ function inlineFragmentArgs({
150300
150303
  filepath,
150301
150304
  document2
150302
150305
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
150306
+ const modifyValue = (node2) => {
150307
+ if (node2.kind == "ObjectValue") {
150308
+ return {
150309
+ ...node2,
150310
+ fields: node2.fields.map((field) => {
150311
+ const modifiedValue = modifyValue(field.value);
150312
+ if (!modifiedValue)
150313
+ return null;
150314
+ return {
150315
+ ...field,
150316
+ value: modifyValue(field.value)
150317
+ };
150318
+ })
150319
+ };
150320
+ }
150321
+ if (node2.kind !== "Variable") {
150322
+ return node2;
150323
+ }
150324
+ if (!scope2) {
150325
+ throw new HoudiniError2({
150326
+ filepath,
150327
+ message: node2.name.value + " is not defined in the current scope: " + JSON.stringify(scope2)
150328
+ });
150329
+ }
150330
+ const newValue = scope2[node2.name.value];
150331
+ if (newValue) {
150332
+ return newValue;
150333
+ }
150334
+ if (definitionArgs[node2.name.value] && definitionArgs[node2.name.value].required) {
150335
+ throw new HoudiniError2({
150336
+ filepath,
150337
+ message: "Missing value for required arg: " + node2.name.value
150338
+ });
150339
+ }
150340
+ return null;
150341
+ };
150303
150342
  const result = esm_default(
150304
150343
  graphql42.visit(document2, {
150305
150344
  FragmentSpread(node2) {
@@ -150373,29 +150412,14 @@ function inlineFragmentArgs({
150373
150412
  }
150374
150413
  },
150375
150414
  Argument(node2) {
150376
- const value2 = node2.value;
150377
- if (value2.kind !== "Variable") {
150378
- return;
150379
- }
150380
- if (!scope2) {
150381
- throw new HoudiniError2({
150382
- filepath,
150383
- message: node2.name.value + " is not defined in the current scope: " + JSON.stringify(scope2)
150384
- });
150385
- }
150386
- const newValue = scope2[value2.name.value];
150415
+ let value2 = node2.value;
150416
+ const newValue = modifyValue(value2);
150387
150417
  if (newValue) {
150388
150418
  return {
150389
150419
  ...node2,
150390
150420
  value: newValue
150391
150421
  };
150392
150422
  }
150393
- if (definitionArgs[value2.name.value] && definitionArgs[value2.name.value].required) {
150394
- throw new HoudiniError2({
150395
- filepath,
150396
- message: "Missing value for required arg: " + value2.name.value
150397
- });
150398
- }
150399
150423
  return null;
150400
150424
  }
150401
150425
  })
@@ -152191,13 +152215,13 @@ function artifactGenerator(stats) {
152191
152215
  });
152192
152216
  }
152193
152217
  const listOfArtifacts = [];
152194
- const hash = config22.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashDocument;
152218
+ const hashPluginBaseRaw = config22.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
152195
152219
  await Promise.all(
152196
152220
  [
152197
152221
  writeIndexFile(config22, docs)
152198
152222
  ].concat(
152199
152223
  docs.map(async (doc) => {
152200
- const { document: document2, name, generateArtifact, originalParsed, originalString } = doc;
152224
+ const { document: document2, name, generateArtifact, originalParsed } = doc;
152201
152225
  if (!generateArtifact) {
152202
152226
  return;
152203
152227
  }
@@ -152304,7 +152328,7 @@ function artifactGenerator(stats) {
152304
152328
  let artifact = {
152305
152329
  name,
152306
152330
  kind: docKind,
152307
- hash: hash({ config: config22, document: doc }),
152331
+ hash: "NOT_YET",
152308
152332
  refetch: doc.refetch,
152309
152333
  raw: rawString,
152310
152334
  rootType,
@@ -152331,6 +152355,8 @@ function artifactGenerator(stats) {
152331
152355
  }),
152332
152356
  pluginData: {}
152333
152357
  };
152358
+ const hash_value = hashPluginBaseRaw({ config: config22, document: { ...doc, artifact } });
152359
+ artifact.hash = hash_value;
152334
152360
  applyMask(
152335
152361
  config22,
152336
152362
  artifact.selection,
@@ -152405,11 +152431,10 @@ function artifactGenerator(stats) {
152405
152431
  }
152406
152432
  plugin2.artifactEnd({ config: config22, document: doc });
152407
152433
  }
152434
+ const _houdiniHash = hashOriginal({ document: doc });
152408
152435
  const file = AST5.program([
152409
152436
  moduleExport(config22, "default", serializeValue(artifact)),
152410
- AST5.expressionStatement(
152411
- AST5.stringLiteral(`HoudiniHash=${hash({ config: config22, document: doc })}`)
152412
- )
152437
+ AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
152413
152438
  ]);
152414
152439
  const artifactPath = config22.artifactPath(document2);
152415
152440
  const countDocument = doc.generateStore;
@@ -152426,10 +152451,12 @@ function artifactGenerator(stats) {
152426
152451
  return;
152427
152452
  }
152428
152453
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
152429
- if (match && match[1] !== artifact.hash) {
152454
+ if (match && match[1] !== _houdiniHash) {
152430
152455
  stats.changed.push(artifact.name);
152431
152456
  }
152432
152457
  stats.total.push(artifact.name);
152458
+ stats.hashSize.push(artifact.hash.length);
152459
+ stats.querySize.push(artifact.raw.length);
152433
152460
  })
152434
152461
  )
152435
152462
  );
@@ -154000,39 +154027,36 @@ async function typescriptGenerator(config22, docs) {
154000
154027
  }
154001
154028
  var graphql19 = __toESM3(require_graphql22(), 1);
154002
154029
  async function persistOutputGenerator(config22, docs) {
154003
- if (typeof config22.persistedQueryPath !== "string" || config22.persistedQueryPath.length === 0)
154004
- return;
154005
- if (!config22.persistedQueryPath.endsWith(".json")) {
154006
- console.log("Can only write the queryMap to a json file");
154007
- return;
154030
+ if (!config22.persistedQueriesPath.endsWith(".json")) {
154031
+ throw new Error('Can write Persisted Queries only in a ".json" file.');
154008
154032
  }
154009
- const queryMap = docs.reduce(
154010
- (acc, { document: document2, generateArtifact }) => {
154011
- if (!generateArtifact) {
154012
- return acc;
154013
- }
154014
- let rawString = graphql19.print(
154015
- graphql19.visit(document2, {
154016
- Directive(node2) {
154017
- if (config22.isInternalDirective(node2.name.value)) {
154018
- return null;
154019
- }
154033
+ const queryMap = docs.reduce((acc, doc) => {
154034
+ const { document: document2, generateArtifact, artifact } = doc;
154035
+ if (!generateArtifact) {
154036
+ return acc;
154037
+ }
154038
+ let rawString = graphql19.print(
154039
+ graphql19.visit(document2, {
154040
+ Directive(node2) {
154041
+ if (config22.isInternalDirective(node2.name.value)) {
154042
+ return null;
154020
154043
  }
154021
- })
154022
- );
154023
- const operations = document2.definitions.filter(
154024
- ({ kind }) => kind === graphql19.Kind.OPERATION_DEFINITION
154025
- );
154026
- if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
154027
- acc[hashDocument({ config: config22, document: rawString })] = rawString;
154044
+ }
154045
+ })
154046
+ );
154047
+ const operations = document2.definitions.filter(
154048
+ ({ kind }) => kind === graphql19.Kind.OPERATION_DEFINITION
154049
+ );
154050
+ if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
154051
+ if (artifact) {
154052
+ acc[artifact.hash] = rawString;
154028
154053
  }
154029
- return acc;
154030
- },
154031
- {}
154032
- );
154054
+ }
154055
+ return acc;
154056
+ }, {});
154033
154057
  if (Object.keys(queryMap).length === 0)
154034
154058
  return;
154035
- await fs_exports2.writeFile(config22.persistedQueryPath, JSON.stringify(queryMap, null, 4));
154059
+ await fs_exports2.writeFile(config22.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
154036
154060
  }
154037
154061
  var graphql20 = __toESM3(require_graphql22(), 1);
154038
154062
  var recast14 = __toESM3(require_main22(), 1);
@@ -155328,7 +155352,9 @@ async function runPipeline22(config22, docs) {
155328
155352
  total: [],
155329
155353
  changed: [],
155330
155354
  new: [],
155331
- deleted: []
155355
+ deleted: [],
155356
+ hashSize: [],
155357
+ querySize: []
155332
155358
  };
155333
155359
  const generatePlugins = config22.plugins.filter((plugin2) => plugin2.generate);
155334
155360
  const afterValidate = config22.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
@@ -155341,6 +155367,9 @@ async function runPipeline22(config22, docs) {
155341
155367
  documents: docs2
155342
155368
  })
155343
155369
  );
155370
+ if (!config22.pluginMode && process.env.HOUDINI_TEST !== "true") {
155371
+ console.log("\u{1F3A9} Generating runtime...");
155372
+ }
155344
155373
  let error2 = null;
155345
155374
  try {
155346
155375
  await runPipeline2(
@@ -155387,9 +155416,6 @@ async function runPipeline22(config22, docs) {
155387
155416
  }
155388
155417
  return;
155389
155418
  }
155390
- if (!config22.pluginMode) {
155391
- console.log("\u{1F3A9} Generating runtime...");
155392
- }
155393
155419
  if (error2) {
155394
155420
  throw error2;
155395
155421
  }
@@ -155414,6 +155440,14 @@ async function runPipeline22(config22, docs) {
155414
155440
  }
155415
155441
  console.log(`${emoji} ${artifact}`);
155416
155442
  }
155443
+ console.log(``);
155444
+ console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
155445
+ const format = (val) => {
155446
+ return `${(val / 1024).toFixed(1)} kb`;
155447
+ };
155448
+ const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
155449
+ const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
155450
+ console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
155417
155451
  }
155418
155452
  }
155419
155453
  function logStyled(kind, stat23, logLevel, plugin2) {
@@ -211839,7 +211873,7 @@ var Config = class {
211839
211873
  projectRoot;
211840
211874
  schema;
211841
211875
  schemaPath;
211842
- persistedQueryPath;
211876
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
211843
211877
  exclude;
211844
211878
  scalars;
211845
211879
  module = "esm";
@@ -211891,7 +211925,8 @@ var Config = class {
211891
211925
  logLevel,
211892
211926
  defaultFragmentMasking = "enable",
211893
211927
  watchSchema,
211894
- projectDir
211928
+ projectDir,
211929
+ persistedQueriesPath
211895
211930
  } = this.configFile;
211896
211931
  if (typeof schema2 === "string") {
211897
211932
  this.schema = graphql27.buildSchema(schema2);
@@ -211928,6 +211963,9 @@ var Config = class {
211928
211963
  this.schemaPollHeaders = watchSchema?.headers ?? {};
211929
211964
  this.rootDir = join4(this.projectRoot, "$houdini");
211930
211965
  this.#fragmentVariableMaps = {};
211966
+ if (persistedQueriesPath) {
211967
+ this.persistedQueriesPath = persistedQueriesPath;
211968
+ }
211931
211969
  if (defaultKeys) {
211932
211970
  this.defaultKeys = defaultKeys;
211933
211971
  }
@@ -308388,7 +308426,7 @@ export const redirect = svelteKitRedirect
308388
308426
  schema({ config: config5 }) {
308389
308427
  return `
308390
308428
  """
308391
- @${config5.loadDirective} is used to disable automatic fetch (no load, no auto fetch in component), you will have to do it manually.
308429
+ @${config5.loadDirective} is used to enable automatic fetch on inline queries.
308392
308430
  """
308393
308431
  directive @${config5.loadDirective} on QUERY
308394
308432
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini-svelte",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "The svelte plugin for houdini",
5
5
  "keywords": [
6
6
  "typescript",
@@ -32,7 +32,7 @@
32
32
  "rollup": "^3.7.4",
33
33
  "svelte": "^3.57.0",
34
34
  "vite": "^4.1.1",
35
- "houdini": "^1.2.6"
35
+ "houdini": "^1.2.7"
36
36
  },
37
37
  "files": [
38
38
  "build"