houdini 1.2.6-next.0 → 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.
Files changed (36) hide show
  1. package/build/cmd-cjs/index.js +110 -74
  2. package/build/cmd-esm/index.js +110 -74
  3. package/build/codegen/generators/artifacts/index.d.ts +2 -0
  4. package/build/codegen-cjs/index.js +101 -69
  5. package/build/codegen-esm/index.js +101 -69
  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 +48 -31
  9. package/build/lib-esm/index.js +46 -30
  10. package/build/runtime/cache/cache.d.ts +1 -0
  11. package/build/runtime/client/documentStore.d.ts +1 -0
  12. package/build/runtime/client/plugins/subscription.d.ts +3 -2
  13. package/build/runtime/lib/config.d.ts +4 -0
  14. package/build/runtime-cjs/cache/cache.d.ts +1 -0
  15. package/build/runtime-cjs/cache/cache.js +6 -8
  16. package/build/runtime-cjs/client/documentStore.d.ts +1 -0
  17. package/build/runtime-cjs/client/documentStore.js +1 -0
  18. package/build/runtime-cjs/client/plugins/fetch.js +14 -5
  19. package/build/runtime-cjs/client/plugins/fetchParams.js +2 -2
  20. package/build/runtime-cjs/client/plugins/subscription.d.ts +3 -2
  21. package/build/runtime-cjs/client/plugins/subscription.js +3 -3
  22. package/build/runtime-cjs/lib/config.d.ts +4 -0
  23. package/build/runtime-esm/cache/cache.d.ts +1 -0
  24. package/build/runtime-esm/cache/cache.js +6 -8
  25. package/build/runtime-esm/client/documentStore.d.ts +1 -0
  26. package/build/runtime-esm/client/documentStore.js +1 -0
  27. package/build/runtime-esm/client/plugins/fetch.js +14 -5
  28. package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
  29. package/build/runtime-esm/client/plugins/subscription.d.ts +3 -2
  30. package/build/runtime-esm/client/plugins/subscription.js +3 -3
  31. package/build/runtime-esm/lib/config.d.ts +4 -0
  32. package/build/test-cjs/index.js +107 -71
  33. package/build/test-esm/index.js +107 -71
  34. package/build/vite-cjs/index.js +107 -71
  35. package/build/vite-esm/index.js +107 -71
  36. package/package.json +1 -1
@@ -68562,12 +68562,9 @@ var CacheInternal = class {
68562
68562
  );
68563
68563
  }
68564
68564
  }
68565
- const embedded = this.idFields(linkedType)?.filter(
68566
- (field2) => typeof value[field2] === "undefined"
68567
- ).length > 0;
68568
68565
  let linkedID = null;
68569
68566
  if (value !== null) {
68570
- linkedID = !embedded ? this.id(linkedType, value) : `${parent2}.${key}`;
68567
+ linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent2}.${key}`;
68571
68568
  }
68572
68569
  let linkChange = linkedID !== previousValue;
68573
68570
  layer.writeLink(parent2, key, linkedID);
@@ -68939,6 +68936,10 @@ var CacheInternal = class {
68939
68936
  computeID(type, data) {
68940
68937
  return computeID(this.config, type, data);
68941
68938
  }
68939
+ isEmbedded(linkedType, value) {
68940
+ const idFields = this.idFields(linkedType);
68941
+ return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
68942
+ }
68942
68943
  hydrateNestedList({
68943
68944
  fields,
68944
68945
  variables,
@@ -69046,9 +69047,6 @@ var CacheInternal = class {
69046
69047
  }
69047
69048
  const entryObj = entry;
69048
69049
  let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
69049
- const embedded = this.idFields(linkedType)?.filter(
69050
- (field) => typeof entry[field] === "undefined"
69051
- ).length > 0;
69052
69050
  let innerType = linkedType;
69053
69051
  const typename = entryObj.__typename;
69054
69052
  if (typename) {
@@ -69056,7 +69054,7 @@ var CacheInternal = class {
69056
69054
  } else if (abstract) {
69057
69055
  throw new Error("Encountered interface type without __typename in the payload");
69058
69056
  }
69059
- if (!embedded) {
69057
+ if (!this.isEmbedded(linkedType, entry)) {
69060
69058
  const id = this.id(innerType, entry);
69061
69059
  if (id) {
69062
69060
  linkedID = id;
@@ -69340,7 +69338,7 @@ var Config = class {
69340
69338
  projectRoot;
69341
69339
  schema;
69342
69340
  schemaPath;
69343
- persistedQueryPath;
69341
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
69344
69342
  exclude;
69345
69343
  scalars;
69346
69344
  module = "esm";
@@ -69392,7 +69390,8 @@ var Config = class {
69392
69390
  logLevel,
69393
69391
  defaultFragmentMasking = "enable",
69394
69392
  watchSchema,
69395
- projectDir
69393
+ projectDir,
69394
+ persistedQueriesPath
69396
69395
  } = this.configFile;
69397
69396
  if (typeof schema === "string") {
69398
69397
  this.schema = graphql2.buildSchema(schema);
@@ -69429,6 +69428,9 @@ var Config = class {
69429
69428
  this.schemaPollHeaders = watchSchema?.headers ?? {};
69430
69429
  this.rootDir = join2(this.projectRoot, "$houdini");
69431
69430
  this.#fragmentVariableMaps = {};
69431
+ if (persistedQueriesPath) {
69432
+ this.persistedQueriesPath = persistedQueriesPath;
69433
+ }
69432
69434
  if (defaultKeys) {
69433
69435
  this.defaultKeys = defaultKeys;
69434
69436
  }
@@ -70143,11 +70145,14 @@ function getRootType(type) {
70143
70145
  }
70144
70146
  return type;
70145
70147
  }
70146
- function hashDocument({
70147
- document
70148
- }) {
70149
- const docString = typeof document === "string" ? document : document.originalString;
70150
- return import_node_crypto.default.createHash("sha256").update(docString ?? "").digest("hex");
70148
+ function hashOriginal({ document }) {
70149
+ return hashDocument(document.originalString);
70150
+ }
70151
+ function hashRaw({ document }) {
70152
+ return hashDocument(document.artifact?.raw);
70153
+ }
70154
+ function hashDocument(str) {
70155
+ return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
70151
70156
  }
70152
70157
  function parentField(ancestors) {
70153
70158
  return walkParentField([...ancestors].sort(() => -1));
@@ -71233,6 +71238,42 @@ function inlineFragmentArgs({
71233
71238
  filepath,
71234
71239
  document
71235
71240
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
71241
+ const modifyValue = (node) => {
71242
+ if (node.kind == "ObjectValue") {
71243
+ return {
71244
+ ...node,
71245
+ fields: node.fields.map((field) => {
71246
+ const modifiedValue = modifyValue(field.value);
71247
+ if (!modifiedValue)
71248
+ return null;
71249
+ return {
71250
+ ...field,
71251
+ value: modifyValue(field.value)
71252
+ };
71253
+ })
71254
+ };
71255
+ }
71256
+ if (node.kind !== "Variable") {
71257
+ return node;
71258
+ }
71259
+ if (!scope) {
71260
+ throw new HoudiniError({
71261
+ filepath,
71262
+ message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
71263
+ });
71264
+ }
71265
+ const newValue = scope[node.name.value];
71266
+ if (newValue) {
71267
+ return newValue;
71268
+ }
71269
+ if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
71270
+ throw new HoudiniError({
71271
+ filepath,
71272
+ message: "Missing value for required arg: " + node.name.value
71273
+ });
71274
+ }
71275
+ return null;
71276
+ };
71236
71277
  const result = esm_default(
71237
71278
  graphql5.visit(document, {
71238
71279
  FragmentSpread(node) {
@@ -71306,29 +71347,14 @@ function inlineFragmentArgs({
71306
71347
  }
71307
71348
  },
71308
71349
  Argument(node) {
71309
- const value = node.value;
71310
- if (value.kind !== "Variable") {
71311
- return;
71312
- }
71313
- if (!scope) {
71314
- throw new HoudiniError({
71315
- filepath,
71316
- message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
71317
- });
71318
- }
71319
- const newValue = scope[value.name.value];
71350
+ let value = node.value;
71351
+ const newValue = modifyValue(value);
71320
71352
  if (newValue) {
71321
71353
  return {
71322
71354
  ...node,
71323
71355
  value: newValue
71324
71356
  };
71325
71357
  }
71326
- if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
71327
- throw new HoudiniError({
71328
- filepath,
71329
- message: "Missing value for required arg: " + value.name.value
71330
- });
71331
- }
71332
71358
  return null;
71333
71359
  }
71334
71360
  })
@@ -73158,13 +73184,13 @@ function artifactGenerator(stats) {
73158
73184
  });
73159
73185
  }
73160
73186
  const listOfArtifacts = [];
73161
- const hash = config4.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashDocument;
73187
+ const hashPluginBaseRaw = config4.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
73162
73188
  await Promise.all(
73163
73189
  [
73164
73190
  writeIndexFile(config4, docs)
73165
73191
  ].concat(
73166
73192
  docs.map(async (doc) => {
73167
- const { document, name, generateArtifact, originalParsed, originalString } = doc;
73193
+ const { document, name, generateArtifact, originalParsed } = doc;
73168
73194
  if (!generateArtifact) {
73169
73195
  return;
73170
73196
  }
@@ -73271,7 +73297,7 @@ function artifactGenerator(stats) {
73271
73297
  let artifact = {
73272
73298
  name,
73273
73299
  kind: docKind,
73274
- hash: hash({ config: config4, document: doc }),
73300
+ hash: "NOT_YET",
73275
73301
  refetch: doc.refetch,
73276
73302
  raw: rawString,
73277
73303
  rootType,
@@ -73298,6 +73324,8 @@ function artifactGenerator(stats) {
73298
73324
  }),
73299
73325
  pluginData: {}
73300
73326
  };
73327
+ const hash_value = hashPluginBaseRaw({ config: config4, document: { ...doc, artifact } });
73328
+ artifact.hash = hash_value;
73301
73329
  applyMask(
73302
73330
  config4,
73303
73331
  artifact.selection,
@@ -73372,11 +73400,10 @@ function artifactGenerator(stats) {
73372
73400
  }
73373
73401
  plugin2.artifactEnd({ config: config4, document: doc });
73374
73402
  }
73403
+ const _houdiniHash = hashOriginal({ document: doc });
73375
73404
  const file = AST5.program([
73376
73405
  moduleExport(config4, "default", serializeValue(artifact)),
73377
- AST5.expressionStatement(
73378
- AST5.stringLiteral(`HoudiniHash=${hash({ config: config4, document: doc })}`)
73379
- )
73406
+ AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
73380
73407
  ]);
73381
73408
  const artifactPath = config4.artifactPath(document);
73382
73409
  const countDocument = doc.generateStore;
@@ -73393,10 +73420,12 @@ function artifactGenerator(stats) {
73393
73420
  return;
73394
73421
  }
73395
73422
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
73396
- if (match && match[1] !== artifact.hash) {
73423
+ if (match && match[1] !== _houdiniHash) {
73397
73424
  stats.changed.push(artifact.name);
73398
73425
  }
73399
73426
  stats.total.push(artifact.name);
73427
+ stats.hashSize.push(artifact.hash.length);
73428
+ stats.querySize.push(artifact.raw.length);
73400
73429
  })
73401
73430
  )
73402
73431
  );
@@ -75001,39 +75030,36 @@ async function typescriptGenerator(config4, docs) {
75001
75030
  // src/codegen/generators/persistedQueries/index.ts
75002
75031
  var graphql20 = __toESM(require_graphql2(), 1);
75003
75032
  async function persistOutputGenerator(config4, docs) {
75004
- if (typeof config4.persistedQueryPath !== "string" || config4.persistedQueryPath.length === 0)
75005
- return;
75006
- if (!config4.persistedQueryPath.endsWith(".json")) {
75007
- console.log("Can only write the queryMap to a json file");
75008
- return;
75033
+ if (!config4.persistedQueriesPath.endsWith(".json")) {
75034
+ throw new Error('Can write Persisted Queries only in a ".json" file.');
75009
75035
  }
75010
- const queryMap = docs.reduce(
75011
- (acc, { document, generateArtifact }) => {
75012
- if (!generateArtifact) {
75013
- return acc;
75014
- }
75015
- let rawString = graphql20.print(
75016
- graphql20.visit(document, {
75017
- Directive(node) {
75018
- if (config4.isInternalDirective(node.name.value)) {
75019
- return null;
75020
- }
75036
+ const queryMap = docs.reduce((acc, doc) => {
75037
+ const { document, generateArtifact, artifact } = doc;
75038
+ if (!generateArtifact) {
75039
+ return acc;
75040
+ }
75041
+ let rawString = graphql20.print(
75042
+ graphql20.visit(document, {
75043
+ Directive(node) {
75044
+ if (config4.isInternalDirective(node.name.value)) {
75045
+ return null;
75021
75046
  }
75022
- })
75023
- );
75024
- const operations = document.definitions.filter(
75025
- ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
75026
- );
75027
- if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
75028
- acc[hashDocument({ config: config4, document: rawString })] = rawString;
75047
+ }
75048
+ })
75049
+ );
75050
+ const operations = document.definitions.filter(
75051
+ ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
75052
+ );
75053
+ if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
75054
+ if (artifact) {
75055
+ acc[artifact.hash] = rawString;
75029
75056
  }
75030
- return acc;
75031
- },
75032
- {}
75033
- );
75057
+ }
75058
+ return acc;
75059
+ }, {});
75034
75060
  if (Object.keys(queryMap).length === 0)
75035
75061
  return;
75036
- await fs_exports.writeFile(config4.persistedQueryPath, JSON.stringify(queryMap, null, 4));
75062
+ await fs_exports.writeFile(config4.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
75037
75063
  }
75038
75064
 
75039
75065
  // src/codegen/generators/definitions/enums.ts
@@ -76355,7 +76381,9 @@ async function runPipeline2(config4, docs) {
76355
76381
  total: [],
76356
76382
  changed: [],
76357
76383
  new: [],
76358
- deleted: []
76384
+ deleted: [],
76385
+ hashSize: [],
76386
+ querySize: []
76359
76387
  };
76360
76388
  const generatePlugins = config4.plugins.filter((plugin2) => plugin2.generate);
76361
76389
  const afterValidate = config4.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
@@ -76368,6 +76396,9 @@ async function runPipeline2(config4, docs) {
76368
76396
  documents: docs2
76369
76397
  })
76370
76398
  );
76399
+ if (!config4.pluginMode && process.env.HOUDINI_TEST !== "true") {
76400
+ console.log("\u{1F3A9} Generating runtime...");
76401
+ }
76371
76402
  let error = null;
76372
76403
  try {
76373
76404
  await runPipeline(
@@ -76414,9 +76445,6 @@ async function runPipeline2(config4, docs) {
76414
76445
  }
76415
76446
  return;
76416
76447
  }
76417
- if (!config4.pluginMode) {
76418
- console.log("\u{1F3A9} Generating runtime...");
76419
- }
76420
76448
  if (error) {
76421
76449
  throw error;
76422
76450
  }
@@ -76441,6 +76469,14 @@ async function runPipeline2(config4, docs) {
76441
76469
  }
76442
76470
  console.log(`${emoji} ${artifact}`);
76443
76471
  }
76472
+ console.log(``);
76473
+ console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
76474
+ const format = (val) => {
76475
+ return `${(val / 1024).toFixed(1)} kb`;
76476
+ };
76477
+ const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
76478
+ const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
76479
+ console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
76444
76480
  }
76445
76481
  }
76446
76482
  async function collectDocuments(config4) {
@@ -68557,12 +68557,9 @@ var CacheInternal = class {
68557
68557
  );
68558
68558
  }
68559
68559
  }
68560
- const embedded = this.idFields(linkedType)?.filter(
68561
- (field2) => typeof value[field2] === "undefined"
68562
- ).length > 0;
68563
68560
  let linkedID = null;
68564
68561
  if (value !== null) {
68565
- linkedID = !embedded ? this.id(linkedType, value) : `${parent2}.${key}`;
68562
+ linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent2}.${key}`;
68566
68563
  }
68567
68564
  let linkChange = linkedID !== previousValue;
68568
68565
  layer.writeLink(parent2, key, linkedID);
@@ -68934,6 +68931,10 @@ var CacheInternal = class {
68934
68931
  computeID(type, data) {
68935
68932
  return computeID(this.config, type, data);
68936
68933
  }
68934
+ isEmbedded(linkedType, value) {
68935
+ const idFields = this.idFields(linkedType);
68936
+ return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
68937
+ }
68937
68938
  hydrateNestedList({
68938
68939
  fields,
68939
68940
  variables,
@@ -69041,9 +69042,6 @@ var CacheInternal = class {
69041
69042
  }
69042
69043
  const entryObj = entry;
69043
69044
  let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
69044
- const embedded = this.idFields(linkedType)?.filter(
69045
- (field) => typeof entry[field] === "undefined"
69046
- ).length > 0;
69047
69045
  let innerType = linkedType;
69048
69046
  const typename = entryObj.__typename;
69049
69047
  if (typename) {
@@ -69051,7 +69049,7 @@ var CacheInternal = class {
69051
69049
  } else if (abstract) {
69052
69050
  throw new Error("Encountered interface type without __typename in the payload");
69053
69051
  }
69054
- if (!embedded) {
69052
+ if (!this.isEmbedded(linkedType, entry)) {
69055
69053
  const id = this.id(innerType, entry);
69056
69054
  if (id) {
69057
69055
  linkedID = id;
@@ -69334,7 +69332,7 @@ var Config = class {
69334
69332
  projectRoot;
69335
69333
  schema;
69336
69334
  schemaPath;
69337
- persistedQueryPath;
69335
+ persistedQueriesPath = "./$houdini/persisted_queries.json";
69338
69336
  exclude;
69339
69337
  scalars;
69340
69338
  module = "esm";
@@ -69386,7 +69384,8 @@ var Config = class {
69386
69384
  logLevel,
69387
69385
  defaultFragmentMasking = "enable",
69388
69386
  watchSchema,
69389
- projectDir
69387
+ projectDir,
69388
+ persistedQueriesPath
69390
69389
  } = this.configFile;
69391
69390
  if (typeof schema === "string") {
69392
69391
  this.schema = graphql2.buildSchema(schema);
@@ -69423,6 +69422,9 @@ var Config = class {
69423
69422
  this.schemaPollHeaders = watchSchema?.headers ?? {};
69424
69423
  this.rootDir = join2(this.projectRoot, "$houdini");
69425
69424
  this.#fragmentVariableMaps = {};
69425
+ if (persistedQueriesPath) {
69426
+ this.persistedQueriesPath = persistedQueriesPath;
69427
+ }
69426
69428
  if (defaultKeys) {
69427
69429
  this.defaultKeys = defaultKeys;
69428
69430
  }
@@ -70137,11 +70139,14 @@ function getRootType(type) {
70137
70139
  }
70138
70140
  return type;
70139
70141
  }
70140
- function hashDocument({
70141
- document
70142
- }) {
70143
- const docString = typeof document === "string" ? document : document.originalString;
70144
- return crypto.createHash("sha256").update(docString ?? "").digest("hex");
70142
+ function hashOriginal({ document }) {
70143
+ return hashDocument(document.originalString);
70144
+ }
70145
+ function hashRaw({ document }) {
70146
+ return hashDocument(document.artifact?.raw);
70147
+ }
70148
+ function hashDocument(str) {
70149
+ return crypto.createHash("sha256").update(str || "").digest("hex");
70145
70150
  }
70146
70151
  function parentField(ancestors) {
70147
70152
  return walkParentField([...ancestors].sort(() => -1));
@@ -71227,6 +71232,42 @@ function inlineFragmentArgs({
71227
71232
  filepath,
71228
71233
  document
71229
71234
  ).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
71235
+ const modifyValue = (node) => {
71236
+ if (node.kind == "ObjectValue") {
71237
+ return {
71238
+ ...node,
71239
+ fields: node.fields.map((field) => {
71240
+ const modifiedValue = modifyValue(field.value);
71241
+ if (!modifiedValue)
71242
+ return null;
71243
+ return {
71244
+ ...field,
71245
+ value: modifyValue(field.value)
71246
+ };
71247
+ })
71248
+ };
71249
+ }
71250
+ if (node.kind !== "Variable") {
71251
+ return node;
71252
+ }
71253
+ if (!scope) {
71254
+ throw new HoudiniError({
71255
+ filepath,
71256
+ message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
71257
+ });
71258
+ }
71259
+ const newValue = scope[node.name.value];
71260
+ if (newValue) {
71261
+ return newValue;
71262
+ }
71263
+ if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
71264
+ throw new HoudiniError({
71265
+ filepath,
71266
+ message: "Missing value for required arg: " + node.name.value
71267
+ });
71268
+ }
71269
+ return null;
71270
+ };
71230
71271
  const result = esm_default(
71231
71272
  graphql5.visit(document, {
71232
71273
  FragmentSpread(node) {
@@ -71300,29 +71341,14 @@ function inlineFragmentArgs({
71300
71341
  }
71301
71342
  },
71302
71343
  Argument(node) {
71303
- const value = node.value;
71304
- if (value.kind !== "Variable") {
71305
- return;
71306
- }
71307
- if (!scope) {
71308
- throw new HoudiniError({
71309
- filepath,
71310
- message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
71311
- });
71312
- }
71313
- const newValue = scope[value.name.value];
71344
+ let value = node.value;
71345
+ const newValue = modifyValue(value);
71314
71346
  if (newValue) {
71315
71347
  return {
71316
71348
  ...node,
71317
71349
  value: newValue
71318
71350
  };
71319
71351
  }
71320
- if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
71321
- throw new HoudiniError({
71322
- filepath,
71323
- message: "Missing value for required arg: " + value.name.value
71324
- });
71325
- }
71326
71352
  return null;
71327
71353
  }
71328
71354
  })
@@ -73152,13 +73178,13 @@ function artifactGenerator(stats) {
73152
73178
  });
73153
73179
  }
73154
73180
  const listOfArtifacts = [];
73155
- const hash = config4.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashDocument;
73181
+ const hashPluginBaseRaw = config4.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
73156
73182
  await Promise.all(
73157
73183
  [
73158
73184
  writeIndexFile(config4, docs)
73159
73185
  ].concat(
73160
73186
  docs.map(async (doc) => {
73161
- const { document, name, generateArtifact, originalParsed, originalString } = doc;
73187
+ const { document, name, generateArtifact, originalParsed } = doc;
73162
73188
  if (!generateArtifact) {
73163
73189
  return;
73164
73190
  }
@@ -73265,7 +73291,7 @@ function artifactGenerator(stats) {
73265
73291
  let artifact = {
73266
73292
  name,
73267
73293
  kind: docKind,
73268
- hash: hash({ config: config4, document: doc }),
73294
+ hash: "NOT_YET",
73269
73295
  refetch: doc.refetch,
73270
73296
  raw: rawString,
73271
73297
  rootType,
@@ -73292,6 +73318,8 @@ function artifactGenerator(stats) {
73292
73318
  }),
73293
73319
  pluginData: {}
73294
73320
  };
73321
+ const hash_value = hashPluginBaseRaw({ config: config4, document: { ...doc, artifact } });
73322
+ artifact.hash = hash_value;
73295
73323
  applyMask(
73296
73324
  config4,
73297
73325
  artifact.selection,
@@ -73366,11 +73394,10 @@ function artifactGenerator(stats) {
73366
73394
  }
73367
73395
  plugin2.artifactEnd({ config: config4, document: doc });
73368
73396
  }
73397
+ const _houdiniHash = hashOriginal({ document: doc });
73369
73398
  const file = AST5.program([
73370
73399
  moduleExport(config4, "default", serializeValue(artifact)),
73371
- AST5.expressionStatement(
73372
- AST5.stringLiteral(`HoudiniHash=${hash({ config: config4, document: doc })}`)
73373
- )
73400
+ AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
73374
73401
  ]);
73375
73402
  const artifactPath = config4.artifactPath(document);
73376
73403
  const countDocument = doc.generateStore;
@@ -73387,10 +73414,12 @@ function artifactGenerator(stats) {
73387
73414
  return;
73388
73415
  }
73389
73416
  const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
73390
- if (match && match[1] !== artifact.hash) {
73417
+ if (match && match[1] !== _houdiniHash) {
73391
73418
  stats.changed.push(artifact.name);
73392
73419
  }
73393
73420
  stats.total.push(artifact.name);
73421
+ stats.hashSize.push(artifact.hash.length);
73422
+ stats.querySize.push(artifact.raw.length);
73394
73423
  })
73395
73424
  )
73396
73425
  );
@@ -74995,39 +75024,36 @@ async function typescriptGenerator(config4, docs) {
74995
75024
  // src/codegen/generators/persistedQueries/index.ts
74996
75025
  var graphql20 = __toESM(require_graphql2(), 1);
74997
75026
  async function persistOutputGenerator(config4, docs) {
74998
- if (typeof config4.persistedQueryPath !== "string" || config4.persistedQueryPath.length === 0)
74999
- return;
75000
- if (!config4.persistedQueryPath.endsWith(".json")) {
75001
- console.log("Can only write the queryMap to a json file");
75002
- return;
75027
+ if (!config4.persistedQueriesPath.endsWith(".json")) {
75028
+ throw new Error('Can write Persisted Queries only in a ".json" file.');
75003
75029
  }
75004
- const queryMap = docs.reduce(
75005
- (acc, { document, generateArtifact }) => {
75006
- if (!generateArtifact) {
75007
- return acc;
75008
- }
75009
- let rawString = graphql20.print(
75010
- graphql20.visit(document, {
75011
- Directive(node) {
75012
- if (config4.isInternalDirective(node.name.value)) {
75013
- return null;
75014
- }
75030
+ const queryMap = docs.reduce((acc, doc) => {
75031
+ const { document, generateArtifact, artifact } = doc;
75032
+ if (!generateArtifact) {
75033
+ return acc;
75034
+ }
75035
+ let rawString = graphql20.print(
75036
+ graphql20.visit(document, {
75037
+ Directive(node) {
75038
+ if (config4.isInternalDirective(node.name.value)) {
75039
+ return null;
75015
75040
  }
75016
- })
75017
- );
75018
- const operations = document.definitions.filter(
75019
- ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
75020
- );
75021
- if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
75022
- acc[hashDocument({ config: config4, document: rawString })] = rawString;
75041
+ }
75042
+ })
75043
+ );
75044
+ const operations = document.definitions.filter(
75045
+ ({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
75046
+ );
75047
+ if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
75048
+ if (artifact) {
75049
+ acc[artifact.hash] = rawString;
75023
75050
  }
75024
- return acc;
75025
- },
75026
- {}
75027
- );
75051
+ }
75052
+ return acc;
75053
+ }, {});
75028
75054
  if (Object.keys(queryMap).length === 0)
75029
75055
  return;
75030
- await fs_exports.writeFile(config4.persistedQueryPath, JSON.stringify(queryMap, null, 4));
75056
+ await fs_exports.writeFile(config4.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
75031
75057
  }
75032
75058
 
75033
75059
  // src/codegen/generators/definitions/enums.ts
@@ -76349,7 +76375,9 @@ async function runPipeline2(config4, docs) {
76349
76375
  total: [],
76350
76376
  changed: [],
76351
76377
  new: [],
76352
- deleted: []
76378
+ deleted: [],
76379
+ hashSize: [],
76380
+ querySize: []
76353
76381
  };
76354
76382
  const generatePlugins = config4.plugins.filter((plugin2) => plugin2.generate);
76355
76383
  const afterValidate = config4.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
@@ -76362,6 +76390,9 @@ async function runPipeline2(config4, docs) {
76362
76390
  documents: docs2
76363
76391
  })
76364
76392
  );
76393
+ if (!config4.pluginMode && process.env.HOUDINI_TEST !== "true") {
76394
+ console.log("\u{1F3A9} Generating runtime...");
76395
+ }
76365
76396
  let error = null;
76366
76397
  try {
76367
76398
  await runPipeline(
@@ -76408,9 +76439,6 @@ async function runPipeline2(config4, docs) {
76408
76439
  }
76409
76440
  return;
76410
76441
  }
76411
- if (!config4.pluginMode) {
76412
- console.log("\u{1F3A9} Generating runtime...");
76413
- }
76414
76442
  if (error) {
76415
76443
  throw error;
76416
76444
  }
@@ -76435,6 +76463,14 @@ async function runPipeline2(config4, docs) {
76435
76463
  }
76436
76464
  console.log(`${emoji} ${artifact}`);
76437
76465
  }
76466
+ console.log(``);
76467
+ console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
76468
+ const format = (val) => {
76469
+ return `${(val / 1024).toFixed(1)} kb`;
76470
+ };
76471
+ const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
76472
+ const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
76473
+ console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
76438
76474
  }
76439
76475
  }
76440
76476
  async function collectDocuments(config4) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "houdini",
3
- "version": "1.2.6-next.0",
3
+ "version": "1.2.7",
4
4
  "description": "The disappearing GraphQL clients",
5
5
  "keywords": [
6
6
  "typescript",