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.
- package/build/cmd-cjs/index.js +110 -74
- package/build/cmd-esm/index.js +110 -74
- package/build/codegen/generators/artifacts/index.d.ts +2 -0
- package/build/codegen-cjs/index.js +101 -69
- package/build/codegen-esm/index.js +101 -69
- package/build/lib/config.d.ts +1 -1
- package/build/lib/graphql.d.ts +5 -3
- package/build/lib-cjs/index.js +48 -31
- package/build/lib-esm/index.js +46 -30
- package/build/runtime/cache/cache.d.ts +1 -0
- package/build/runtime/client/documentStore.d.ts +1 -0
- package/build/runtime/client/plugins/subscription.d.ts +3 -2
- package/build/runtime/lib/config.d.ts +4 -0
- package/build/runtime-cjs/cache/cache.d.ts +1 -0
- package/build/runtime-cjs/cache/cache.js +6 -8
- package/build/runtime-cjs/client/documentStore.d.ts +1 -0
- package/build/runtime-cjs/client/documentStore.js +1 -0
- package/build/runtime-cjs/client/plugins/fetch.js +14 -5
- package/build/runtime-cjs/client/plugins/fetchParams.js +2 -2
- package/build/runtime-cjs/client/plugins/subscription.d.ts +3 -2
- package/build/runtime-cjs/client/plugins/subscription.js +3 -3
- package/build/runtime-cjs/lib/config.d.ts +4 -0
- package/build/runtime-esm/cache/cache.d.ts +1 -0
- package/build/runtime-esm/cache/cache.js +6 -8
- package/build/runtime-esm/client/documentStore.d.ts +1 -0
- package/build/runtime-esm/client/documentStore.js +1 -0
- package/build/runtime-esm/client/plugins/fetch.js +14 -5
- package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
- package/build/runtime-esm/client/plugins/subscription.d.ts +3 -2
- package/build/runtime-esm/client/plugins/subscription.js +3 -3
- package/build/runtime-esm/lib/config.d.ts +4 -0
- package/build/test-cjs/index.js +107 -71
- package/build/test-esm/index.js +107 -71
- package/build/vite-cjs/index.js +107 -71
- package/build/vite-esm/index.js +107 -71
- package/package.json +1 -1
package/build/cmd-esm/index.js
CHANGED
|
@@ -71703,12 +71703,9 @@ var CacheInternal = class {
|
|
|
71703
71703
|
);
|
|
71704
71704
|
}
|
|
71705
71705
|
}
|
|
71706
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
71707
|
-
(field2) => typeof value[field2] === "undefined"
|
|
71708
|
-
).length > 0;
|
|
71709
71706
|
let linkedID = null;
|
|
71710
71707
|
if (value !== null) {
|
|
71711
|
-
linkedID = !
|
|
71708
|
+
linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent2}.${key}`;
|
|
71712
71709
|
}
|
|
71713
71710
|
let linkChange = linkedID !== previousValue;
|
|
71714
71711
|
layer.writeLink(parent2, key, linkedID);
|
|
@@ -72080,6 +72077,10 @@ var CacheInternal = class {
|
|
|
72080
72077
|
computeID(type, data) {
|
|
72081
72078
|
return computeID(this.config, type, data);
|
|
72082
72079
|
}
|
|
72080
|
+
isEmbedded(linkedType, value) {
|
|
72081
|
+
const idFields = this.idFields(linkedType);
|
|
72082
|
+
return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
|
|
72083
|
+
}
|
|
72083
72084
|
hydrateNestedList({
|
|
72084
72085
|
fields,
|
|
72085
72086
|
variables,
|
|
@@ -72187,9 +72188,6 @@ var CacheInternal = class {
|
|
|
72187
72188
|
}
|
|
72188
72189
|
const entryObj = entry;
|
|
72189
72190
|
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
72190
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
72191
|
-
(field) => typeof entry[field] === "undefined"
|
|
72192
|
-
).length > 0;
|
|
72193
72191
|
let innerType = linkedType;
|
|
72194
72192
|
const typename = entryObj.__typename;
|
|
72195
72193
|
if (typename) {
|
|
@@ -72197,7 +72195,7 @@ var CacheInternal = class {
|
|
|
72197
72195
|
} else if (abstract) {
|
|
72198
72196
|
throw new Error("Encountered interface type without __typename in the payload");
|
|
72199
72197
|
}
|
|
72200
|
-
if (!
|
|
72198
|
+
if (!this.isEmbedded(linkedType, entry)) {
|
|
72201
72199
|
const id = this.id(innerType, entry);
|
|
72202
72200
|
if (id) {
|
|
72203
72201
|
linkedID = id;
|
|
@@ -72480,7 +72478,7 @@ var Config = class {
|
|
|
72480
72478
|
projectRoot;
|
|
72481
72479
|
schema;
|
|
72482
72480
|
schemaPath;
|
|
72483
|
-
|
|
72481
|
+
persistedQueriesPath = "./$houdini/persisted_queries.json";
|
|
72484
72482
|
exclude;
|
|
72485
72483
|
scalars;
|
|
72486
72484
|
module = "esm";
|
|
@@ -72532,7 +72530,8 @@ var Config = class {
|
|
|
72532
72530
|
logLevel,
|
|
72533
72531
|
defaultFragmentMasking = "enable",
|
|
72534
72532
|
watchSchema,
|
|
72535
|
-
projectDir
|
|
72533
|
+
projectDir,
|
|
72534
|
+
persistedQueriesPath
|
|
72536
72535
|
} = this.configFile;
|
|
72537
72536
|
if (typeof schema === "string") {
|
|
72538
72537
|
this.schema = graphql2.buildSchema(schema);
|
|
@@ -72569,6 +72568,9 @@ var Config = class {
|
|
|
72569
72568
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
72570
72569
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
72571
72570
|
this.#fragmentVariableMaps = {};
|
|
72571
|
+
if (persistedQueriesPath) {
|
|
72572
|
+
this.persistedQueriesPath = persistedQueriesPath;
|
|
72573
|
+
}
|
|
72572
72574
|
if (defaultKeys) {
|
|
72573
72575
|
this.defaultKeys = defaultKeys;
|
|
72574
72576
|
}
|
|
@@ -73283,11 +73285,14 @@ function getRootType(type) {
|
|
|
73283
73285
|
}
|
|
73284
73286
|
return type;
|
|
73285
73287
|
}
|
|
73286
|
-
function
|
|
73287
|
-
document
|
|
73288
|
-
}
|
|
73289
|
-
|
|
73290
|
-
return
|
|
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");
|
|
73291
73296
|
}
|
|
73292
73297
|
function parentField(ancestors) {
|
|
73293
73298
|
return walkParentField([...ancestors].sort(() => -1));
|
|
@@ -74431,6 +74436,42 @@ function inlineFragmentArgs({
|
|
|
74431
74436
|
filepath,
|
|
74432
74437
|
document
|
|
74433
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
|
+
};
|
|
74434
74475
|
const result = esm_default(
|
|
74435
74476
|
graphql5.visit(document, {
|
|
74436
74477
|
FragmentSpread(node) {
|
|
@@ -74504,29 +74545,14 @@ function inlineFragmentArgs({
|
|
|
74504
74545
|
}
|
|
74505
74546
|
},
|
|
74506
74547
|
Argument(node) {
|
|
74507
|
-
|
|
74508
|
-
|
|
74509
|
-
return;
|
|
74510
|
-
}
|
|
74511
|
-
if (!scope) {
|
|
74512
|
-
throw new HoudiniError({
|
|
74513
|
-
filepath,
|
|
74514
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
74515
|
-
});
|
|
74516
|
-
}
|
|
74517
|
-
const newValue = scope[value.name.value];
|
|
74548
|
+
let value = node.value;
|
|
74549
|
+
const newValue = modifyValue(value);
|
|
74518
74550
|
if (newValue) {
|
|
74519
74551
|
return {
|
|
74520
74552
|
...node,
|
|
74521
74553
|
value: newValue
|
|
74522
74554
|
};
|
|
74523
74555
|
}
|
|
74524
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
74525
|
-
throw new HoudiniError({
|
|
74526
|
-
filepath,
|
|
74527
|
-
message: "Missing value for required arg: " + value.name.value
|
|
74528
|
-
});
|
|
74529
|
-
}
|
|
74530
74556
|
return null;
|
|
74531
74557
|
}
|
|
74532
74558
|
})
|
|
@@ -76350,13 +76376,13 @@ function artifactGenerator(stats) {
|
|
|
76350
76376
|
});
|
|
76351
76377
|
}
|
|
76352
76378
|
const listOfArtifacts = [];
|
|
76353
|
-
const
|
|
76379
|
+
const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
|
|
76354
76380
|
await Promise.all(
|
|
76355
76381
|
[
|
|
76356
76382
|
writeIndexFile(config2, docs)
|
|
76357
76383
|
].concat(
|
|
76358
76384
|
docs.map(async (doc) => {
|
|
76359
|
-
const { document, name, generateArtifact, originalParsed
|
|
76385
|
+
const { document, name, generateArtifact, originalParsed } = doc;
|
|
76360
76386
|
if (!generateArtifact) {
|
|
76361
76387
|
return;
|
|
76362
76388
|
}
|
|
@@ -76463,7 +76489,7 @@ function artifactGenerator(stats) {
|
|
|
76463
76489
|
let artifact = {
|
|
76464
76490
|
name,
|
|
76465
76491
|
kind: docKind,
|
|
76466
|
-
hash:
|
|
76492
|
+
hash: "NOT_YET",
|
|
76467
76493
|
refetch: doc.refetch,
|
|
76468
76494
|
raw: rawString,
|
|
76469
76495
|
rootType,
|
|
@@ -76490,6 +76516,8 @@ function artifactGenerator(stats) {
|
|
|
76490
76516
|
}),
|
|
76491
76517
|
pluginData: {}
|
|
76492
76518
|
};
|
|
76519
|
+
const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
|
|
76520
|
+
artifact.hash = hash_value;
|
|
76493
76521
|
applyMask(
|
|
76494
76522
|
config2,
|
|
76495
76523
|
artifact.selection,
|
|
@@ -76564,11 +76592,10 @@ function artifactGenerator(stats) {
|
|
|
76564
76592
|
}
|
|
76565
76593
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
76566
76594
|
}
|
|
76595
|
+
const _houdiniHash = hashOriginal({ document: doc });
|
|
76567
76596
|
const file = AST5.program([
|
|
76568
76597
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
76569
|
-
AST5.expressionStatement(
|
|
76570
|
-
AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
|
|
76571
|
-
)
|
|
76598
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
76572
76599
|
]);
|
|
76573
76600
|
const artifactPath = config2.artifactPath(document);
|
|
76574
76601
|
const countDocument = doc.generateStore;
|
|
@@ -76585,10 +76612,12 @@ function artifactGenerator(stats) {
|
|
|
76585
76612
|
return;
|
|
76586
76613
|
}
|
|
76587
76614
|
const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
|
|
76588
|
-
if (match && match[1] !==
|
|
76615
|
+
if (match && match[1] !== _houdiniHash) {
|
|
76589
76616
|
stats.changed.push(artifact.name);
|
|
76590
76617
|
}
|
|
76591
76618
|
stats.total.push(artifact.name);
|
|
76619
|
+
stats.hashSize.push(artifact.hash.length);
|
|
76620
|
+
stats.querySize.push(artifact.raw.length);
|
|
76592
76621
|
})
|
|
76593
76622
|
)
|
|
76594
76623
|
);
|
|
@@ -78193,39 +78222,36 @@ async function typescriptGenerator(config2, docs) {
|
|
|
78193
78222
|
// src/codegen/generators/persistedQueries/index.ts
|
|
78194
78223
|
var graphql20 = __toESM(require_graphql2(), 1);
|
|
78195
78224
|
async function persistOutputGenerator(config2, docs) {
|
|
78196
|
-
if (
|
|
78197
|
-
|
|
78198
|
-
if (!config2.persistedQueryPath.endsWith(".json")) {
|
|
78199
|
-
console.log("Can only write the queryMap to a json file");
|
|
78200
|
-
return;
|
|
78225
|
+
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
78226
|
+
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
78201
78227
|
}
|
|
78202
|
-
const queryMap = docs.reduce(
|
|
78203
|
-
|
|
78204
|
-
|
|
78205
|
-
|
|
78206
|
-
|
|
78207
|
-
|
|
78208
|
-
|
|
78209
|
-
|
|
78210
|
-
|
|
78211
|
-
|
|
78212
|
-
}
|
|
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;
|
|
78213
78238
|
}
|
|
78214
|
-
}
|
|
78215
|
-
)
|
|
78216
|
-
|
|
78217
|
-
|
|
78218
|
-
)
|
|
78219
|
-
|
|
78220
|
-
|
|
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;
|
|
78221
78248
|
}
|
|
78222
|
-
|
|
78223
|
-
|
|
78224
|
-
|
|
78225
|
-
);
|
|
78249
|
+
}
|
|
78250
|
+
return acc;
|
|
78251
|
+
}, {});
|
|
78226
78252
|
if (Object.keys(queryMap).length === 0)
|
|
78227
78253
|
return;
|
|
78228
|
-
await fs_exports.writeFile(config2.
|
|
78254
|
+
await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
|
|
78229
78255
|
}
|
|
78230
78256
|
|
|
78231
78257
|
// src/codegen/generators/definitions/enums.ts
|
|
@@ -79547,7 +79573,9 @@ async function runPipeline2(config2, docs) {
|
|
|
79547
79573
|
total: [],
|
|
79548
79574
|
changed: [],
|
|
79549
79575
|
new: [],
|
|
79550
|
-
deleted: []
|
|
79576
|
+
deleted: [],
|
|
79577
|
+
hashSize: [],
|
|
79578
|
+
querySize: []
|
|
79551
79579
|
};
|
|
79552
79580
|
const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
|
|
79553
79581
|
const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
|
|
@@ -79560,6 +79588,9 @@ async function runPipeline2(config2, docs) {
|
|
|
79560
79588
|
documents: docs2
|
|
79561
79589
|
})
|
|
79562
79590
|
);
|
|
79591
|
+
if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
|
|
79592
|
+
console.log("\u{1F3A9} Generating runtime...");
|
|
79593
|
+
}
|
|
79563
79594
|
let error = null;
|
|
79564
79595
|
try {
|
|
79565
79596
|
await runPipeline(
|
|
@@ -79606,9 +79637,6 @@ async function runPipeline2(config2, docs) {
|
|
|
79606
79637
|
}
|
|
79607
79638
|
return;
|
|
79608
79639
|
}
|
|
79609
|
-
if (!config2.pluginMode) {
|
|
79610
|
-
console.log("\u{1F3A9} Generating runtime...");
|
|
79611
|
-
}
|
|
79612
79640
|
if (error) {
|
|
79613
79641
|
throw error;
|
|
79614
79642
|
}
|
|
@@ -79633,6 +79661,14 @@ async function runPipeline2(config2, docs) {
|
|
|
79633
79661
|
}
|
|
79634
79662
|
console.log(`${emoji} ${artifact}`);
|
|
79635
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})`);
|
|
79636
79672
|
}
|
|
79637
79673
|
}
|
|
79638
79674
|
async function collectDocuments(config2) {
|
|
@@ -79845,7 +79881,7 @@ async function generate(args = {
|
|
|
79845
79881
|
try {
|
|
79846
79882
|
config2 = await getConfig(extraConfig);
|
|
79847
79883
|
if (args.output) {
|
|
79848
|
-
config2.
|
|
79884
|
+
config2.persistedQueriesPath = args.output;
|
|
79849
79885
|
}
|
|
79850
79886
|
if (args.pullSchema && await config2.apiURL()) {
|
|
79851
79887
|
await pullSchema_default(args);
|
|
@@ -80234,8 +80270,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
80234
80270
|
}
|
|
80235
80271
|
packageJSON.devDependencies = {
|
|
80236
80272
|
...packageJSON.devDependencies,
|
|
80237
|
-
houdini: "^1.2.
|
|
80238
|
-
"houdini-svelte": "^1.2.
|
|
80273
|
+
houdini: "^1.2.7",
|
|
80274
|
+
"houdini-svelte": "^1.2.7"
|
|
80239
80275
|
};
|
|
80240
80276
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
80241
80277
|
}
|
|
@@ -56175,12 +56175,9 @@ var CacheInternal = class {
|
|
|
56175
56175
|
);
|
|
56176
56176
|
}
|
|
56177
56177
|
}
|
|
56178
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
56179
|
-
(field2) => typeof value[field2] === "undefined"
|
|
56180
|
-
).length > 0;
|
|
56181
56178
|
let linkedID = null;
|
|
56182
56179
|
if (value !== null) {
|
|
56183
|
-
linkedID = !
|
|
56180
|
+
linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent2}.${key}`;
|
|
56184
56181
|
}
|
|
56185
56182
|
let linkChange = linkedID !== previousValue;
|
|
56186
56183
|
layer.writeLink(parent2, key, linkedID);
|
|
@@ -56552,6 +56549,10 @@ var CacheInternal = class {
|
|
|
56552
56549
|
computeID(type, data) {
|
|
56553
56550
|
return computeID(this.config, type, data);
|
|
56554
56551
|
}
|
|
56552
|
+
isEmbedded(linkedType, value) {
|
|
56553
|
+
const idFields = this.idFields(linkedType);
|
|
56554
|
+
return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
|
|
56555
|
+
}
|
|
56555
56556
|
hydrateNestedList({
|
|
56556
56557
|
fields,
|
|
56557
56558
|
variables,
|
|
@@ -56659,9 +56660,6 @@ var CacheInternal = class {
|
|
|
56659
56660
|
}
|
|
56660
56661
|
const entryObj = entry;
|
|
56661
56662
|
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
56662
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
56663
|
-
(field) => typeof entry[field] === "undefined"
|
|
56664
|
-
).length > 0;
|
|
56665
56663
|
let innerType = linkedType;
|
|
56666
56664
|
const typename = entryObj.__typename;
|
|
56667
56665
|
if (typename) {
|
|
@@ -56669,7 +56667,7 @@ var CacheInternal = class {
|
|
|
56669
56667
|
} else if (abstract) {
|
|
56670
56668
|
throw new Error("Encountered interface type without __typename in the payload");
|
|
56671
56669
|
}
|
|
56672
|
-
if (!
|
|
56670
|
+
if (!this.isEmbedded(linkedType, entry)) {
|
|
56673
56671
|
const id = this.id(innerType, entry);
|
|
56674
56672
|
if (id) {
|
|
56675
56673
|
linkedID = id;
|
|
@@ -56963,11 +56961,14 @@ function getRootType(type) {
|
|
|
56963
56961
|
}
|
|
56964
56962
|
return type;
|
|
56965
56963
|
}
|
|
56966
|
-
function
|
|
56967
|
-
document
|
|
56968
|
-
}
|
|
56969
|
-
|
|
56970
|
-
return
|
|
56964
|
+
function hashOriginal({ document }) {
|
|
56965
|
+
return hashDocument(document.originalString);
|
|
56966
|
+
}
|
|
56967
|
+
function hashRaw({ document }) {
|
|
56968
|
+
return hashDocument(document.artifact?.raw);
|
|
56969
|
+
}
|
|
56970
|
+
function hashDocument(str) {
|
|
56971
|
+
return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
|
|
56971
56972
|
}
|
|
56972
56973
|
function parentField(ancestors) {
|
|
56973
56974
|
return walkParentField([...ancestors].sort(() => -1));
|
|
@@ -58035,6 +58036,42 @@ function inlineFragmentArgs({
|
|
|
58035
58036
|
filepath,
|
|
58036
58037
|
document
|
|
58037
58038
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
58039
|
+
const modifyValue = (node) => {
|
|
58040
|
+
if (node.kind == "ObjectValue") {
|
|
58041
|
+
return {
|
|
58042
|
+
...node,
|
|
58043
|
+
fields: node.fields.map((field) => {
|
|
58044
|
+
const modifiedValue = modifyValue(field.value);
|
|
58045
|
+
if (!modifiedValue)
|
|
58046
|
+
return null;
|
|
58047
|
+
return {
|
|
58048
|
+
...field,
|
|
58049
|
+
value: modifyValue(field.value)
|
|
58050
|
+
};
|
|
58051
|
+
})
|
|
58052
|
+
};
|
|
58053
|
+
}
|
|
58054
|
+
if (node.kind !== "Variable") {
|
|
58055
|
+
return node;
|
|
58056
|
+
}
|
|
58057
|
+
if (!scope) {
|
|
58058
|
+
throw new HoudiniError({
|
|
58059
|
+
filepath,
|
|
58060
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58061
|
+
});
|
|
58062
|
+
}
|
|
58063
|
+
const newValue = scope[node.name.value];
|
|
58064
|
+
if (newValue) {
|
|
58065
|
+
return newValue;
|
|
58066
|
+
}
|
|
58067
|
+
if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
|
|
58068
|
+
throw new HoudiniError({
|
|
58069
|
+
filepath,
|
|
58070
|
+
message: "Missing value for required arg: " + node.name.value
|
|
58071
|
+
});
|
|
58072
|
+
}
|
|
58073
|
+
return null;
|
|
58074
|
+
};
|
|
58038
58075
|
const result = esm_default(
|
|
58039
58076
|
graphql4.visit(document, {
|
|
58040
58077
|
FragmentSpread(node) {
|
|
@@ -58108,29 +58145,14 @@ function inlineFragmentArgs({
|
|
|
58108
58145
|
}
|
|
58109
58146
|
},
|
|
58110
58147
|
Argument(node) {
|
|
58111
|
-
|
|
58112
|
-
|
|
58113
|
-
return;
|
|
58114
|
-
}
|
|
58115
|
-
if (!scope) {
|
|
58116
|
-
throw new HoudiniError({
|
|
58117
|
-
filepath,
|
|
58118
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58119
|
-
});
|
|
58120
|
-
}
|
|
58121
|
-
const newValue = scope[value.name.value];
|
|
58148
|
+
let value = node.value;
|
|
58149
|
+
const newValue = modifyValue(value);
|
|
58122
58150
|
if (newValue) {
|
|
58123
58151
|
return {
|
|
58124
58152
|
...node,
|
|
58125
58153
|
value: newValue
|
|
58126
58154
|
};
|
|
58127
58155
|
}
|
|
58128
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
58129
|
-
throw new HoudiniError({
|
|
58130
|
-
filepath,
|
|
58131
|
-
message: "Missing value for required arg: " + value.name.value
|
|
58132
|
-
});
|
|
58133
|
-
}
|
|
58134
58156
|
return null;
|
|
58135
58157
|
}
|
|
58136
58158
|
})
|
|
@@ -59954,13 +59976,13 @@ function artifactGenerator(stats) {
|
|
|
59954
59976
|
});
|
|
59955
59977
|
}
|
|
59956
59978
|
const listOfArtifacts = [];
|
|
59957
|
-
const
|
|
59979
|
+
const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
|
|
59958
59980
|
await Promise.all(
|
|
59959
59981
|
[
|
|
59960
59982
|
writeIndexFile(config2, docs)
|
|
59961
59983
|
].concat(
|
|
59962
59984
|
docs.map(async (doc) => {
|
|
59963
|
-
const { document, name, generateArtifact, originalParsed
|
|
59985
|
+
const { document, name, generateArtifact, originalParsed } = doc;
|
|
59964
59986
|
if (!generateArtifact) {
|
|
59965
59987
|
return;
|
|
59966
59988
|
}
|
|
@@ -60067,7 +60089,7 @@ function artifactGenerator(stats) {
|
|
|
60067
60089
|
let artifact = {
|
|
60068
60090
|
name,
|
|
60069
60091
|
kind: docKind,
|
|
60070
|
-
hash:
|
|
60092
|
+
hash: "NOT_YET",
|
|
60071
60093
|
refetch: doc.refetch,
|
|
60072
60094
|
raw: rawString,
|
|
60073
60095
|
rootType,
|
|
@@ -60094,6 +60116,8 @@ function artifactGenerator(stats) {
|
|
|
60094
60116
|
}),
|
|
60095
60117
|
pluginData: {}
|
|
60096
60118
|
};
|
|
60119
|
+
const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
|
|
60120
|
+
artifact.hash = hash_value;
|
|
60097
60121
|
applyMask(
|
|
60098
60122
|
config2,
|
|
60099
60123
|
artifact.selection,
|
|
@@ -60168,11 +60192,10 @@ function artifactGenerator(stats) {
|
|
|
60168
60192
|
}
|
|
60169
60193
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
60170
60194
|
}
|
|
60195
|
+
const _houdiniHash = hashOriginal({ document: doc });
|
|
60171
60196
|
const file = AST5.program([
|
|
60172
60197
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
60173
|
-
AST5.expressionStatement(
|
|
60174
|
-
AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
|
|
60175
|
-
)
|
|
60198
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
60176
60199
|
]);
|
|
60177
60200
|
const artifactPath = config2.artifactPath(document);
|
|
60178
60201
|
const countDocument = doc.generateStore;
|
|
@@ -60189,10 +60212,12 @@ function artifactGenerator(stats) {
|
|
|
60189
60212
|
return;
|
|
60190
60213
|
}
|
|
60191
60214
|
const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
|
|
60192
|
-
if (match && match[1] !==
|
|
60215
|
+
if (match && match[1] !== _houdiniHash) {
|
|
60193
60216
|
stats.changed.push(artifact.name);
|
|
60194
60217
|
}
|
|
60195
60218
|
stats.total.push(artifact.name);
|
|
60219
|
+
stats.hashSize.push(artifact.hash.length);
|
|
60220
|
+
stats.querySize.push(artifact.raw.length);
|
|
60196
60221
|
})
|
|
60197
60222
|
)
|
|
60198
60223
|
);
|
|
@@ -61797,39 +61822,36 @@ async function typescriptGenerator(config2, docs) {
|
|
|
61797
61822
|
// src/codegen/generators/persistedQueries/index.ts
|
|
61798
61823
|
var graphql19 = __toESM(require_graphql2(), 1);
|
|
61799
61824
|
async function persistOutputGenerator(config2, docs) {
|
|
61800
|
-
if (
|
|
61801
|
-
|
|
61802
|
-
if (!config2.persistedQueryPath.endsWith(".json")) {
|
|
61803
|
-
console.log("Can only write the queryMap to a json file");
|
|
61804
|
-
return;
|
|
61825
|
+
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
61826
|
+
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
61805
61827
|
}
|
|
61806
|
-
const queryMap = docs.reduce(
|
|
61807
|
-
|
|
61808
|
-
|
|
61809
|
-
|
|
61810
|
-
|
|
61811
|
-
|
|
61812
|
-
|
|
61813
|
-
|
|
61814
|
-
|
|
61815
|
-
|
|
61816
|
-
}
|
|
61828
|
+
const queryMap = docs.reduce((acc, doc) => {
|
|
61829
|
+
const { document, generateArtifact, artifact } = doc;
|
|
61830
|
+
if (!generateArtifact) {
|
|
61831
|
+
return acc;
|
|
61832
|
+
}
|
|
61833
|
+
let rawString = graphql19.print(
|
|
61834
|
+
graphql19.visit(document, {
|
|
61835
|
+
Directive(node) {
|
|
61836
|
+
if (config2.isInternalDirective(node.name.value)) {
|
|
61837
|
+
return null;
|
|
61817
61838
|
}
|
|
61818
|
-
}
|
|
61819
|
-
)
|
|
61820
|
-
|
|
61821
|
-
|
|
61822
|
-
)
|
|
61823
|
-
|
|
61824
|
-
|
|
61839
|
+
}
|
|
61840
|
+
})
|
|
61841
|
+
);
|
|
61842
|
+
const operations = document.definitions.filter(
|
|
61843
|
+
({ kind }) => kind === graphql19.Kind.OPERATION_DEFINITION
|
|
61844
|
+
);
|
|
61845
|
+
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
61846
|
+
if (artifact) {
|
|
61847
|
+
acc[artifact.hash] = rawString;
|
|
61825
61848
|
}
|
|
61826
|
-
|
|
61827
|
-
|
|
61828
|
-
|
|
61829
|
-
);
|
|
61849
|
+
}
|
|
61850
|
+
return acc;
|
|
61851
|
+
}, {});
|
|
61830
61852
|
if (Object.keys(queryMap).length === 0)
|
|
61831
61853
|
return;
|
|
61832
|
-
await fs_exports.writeFile(config2.
|
|
61854
|
+
await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
|
|
61833
61855
|
}
|
|
61834
61856
|
|
|
61835
61857
|
// src/codegen/generators/definitions/enums.ts
|
|
@@ -63151,7 +63173,9 @@ async function runPipeline2(config2, docs) {
|
|
|
63151
63173
|
total: [],
|
|
63152
63174
|
changed: [],
|
|
63153
63175
|
new: [],
|
|
63154
|
-
deleted: []
|
|
63176
|
+
deleted: [],
|
|
63177
|
+
hashSize: [],
|
|
63178
|
+
querySize: []
|
|
63155
63179
|
};
|
|
63156
63180
|
const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
|
|
63157
63181
|
const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
|
|
@@ -63164,6 +63188,9 @@ async function runPipeline2(config2, docs) {
|
|
|
63164
63188
|
documents: docs2
|
|
63165
63189
|
})
|
|
63166
63190
|
);
|
|
63191
|
+
if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
|
|
63192
|
+
console.log("\u{1F3A9} Generating runtime...");
|
|
63193
|
+
}
|
|
63167
63194
|
let error = null;
|
|
63168
63195
|
try {
|
|
63169
63196
|
await runPipeline(
|
|
@@ -63210,9 +63237,6 @@ async function runPipeline2(config2, docs) {
|
|
|
63210
63237
|
}
|
|
63211
63238
|
return;
|
|
63212
63239
|
}
|
|
63213
|
-
if (!config2.pluginMode) {
|
|
63214
|
-
console.log("\u{1F3A9} Generating runtime...");
|
|
63215
|
-
}
|
|
63216
63240
|
if (error) {
|
|
63217
63241
|
throw error;
|
|
63218
63242
|
}
|
|
@@ -63237,6 +63261,14 @@ async function runPipeline2(config2, docs) {
|
|
|
63237
63261
|
}
|
|
63238
63262
|
console.log(`${emoji} ${artifact}`);
|
|
63239
63263
|
}
|
|
63264
|
+
console.log(``);
|
|
63265
|
+
console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
|
|
63266
|
+
const format = (val) => {
|
|
63267
|
+
return `${(val / 1024).toFixed(1)} kb`;
|
|
63268
|
+
};
|
|
63269
|
+
const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
|
|
63270
|
+
const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
|
|
63271
|
+
console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
|
|
63240
63272
|
}
|
|
63241
63273
|
}
|
|
63242
63274
|
async function collectDocuments(config2) {
|