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/test-cjs/index.js
CHANGED
|
@@ -56179,12 +56179,9 @@ var CacheInternal = class {
|
|
|
56179
56179
|
);
|
|
56180
56180
|
}
|
|
56181
56181
|
}
|
|
56182
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
56183
|
-
(field2) => typeof value[field2] === "undefined"
|
|
56184
|
-
).length > 0;
|
|
56185
56182
|
let linkedID = null;
|
|
56186
56183
|
if (value !== null) {
|
|
56187
|
-
linkedID = !
|
|
56184
|
+
linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent2}.${key}`;
|
|
56188
56185
|
}
|
|
56189
56186
|
let linkChange = linkedID !== previousValue;
|
|
56190
56187
|
layer.writeLink(parent2, key, linkedID);
|
|
@@ -56556,6 +56553,10 @@ var CacheInternal = class {
|
|
|
56556
56553
|
computeID(type, data) {
|
|
56557
56554
|
return computeID(this.config, type, data);
|
|
56558
56555
|
}
|
|
56556
|
+
isEmbedded(linkedType, value) {
|
|
56557
|
+
const idFields = this.idFields(linkedType);
|
|
56558
|
+
return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
|
|
56559
|
+
}
|
|
56559
56560
|
hydrateNestedList({
|
|
56560
56561
|
fields,
|
|
56561
56562
|
variables,
|
|
@@ -56663,9 +56664,6 @@ var CacheInternal = class {
|
|
|
56663
56664
|
}
|
|
56664
56665
|
const entryObj = entry;
|
|
56665
56666
|
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
56666
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
56667
|
-
(field) => typeof entry[field] === "undefined"
|
|
56668
|
-
).length > 0;
|
|
56669
56667
|
let innerType = linkedType;
|
|
56670
56668
|
const typename = entryObj.__typename;
|
|
56671
56669
|
if (typename) {
|
|
@@ -56673,7 +56671,7 @@ var CacheInternal = class {
|
|
|
56673
56671
|
} else if (abstract) {
|
|
56674
56672
|
throw new Error("Encountered interface type without __typename in the payload");
|
|
56675
56673
|
}
|
|
56676
|
-
if (!
|
|
56674
|
+
if (!this.isEmbedded(linkedType, entry)) {
|
|
56677
56675
|
const id = this.id(innerType, entry);
|
|
56678
56676
|
if (id) {
|
|
56679
56677
|
linkedID = id;
|
|
@@ -56957,7 +56955,7 @@ var Config = class {
|
|
|
56957
56955
|
projectRoot;
|
|
56958
56956
|
schema;
|
|
56959
56957
|
schemaPath;
|
|
56960
|
-
|
|
56958
|
+
persistedQueriesPath = "./$houdini/persisted_queries.json";
|
|
56961
56959
|
exclude;
|
|
56962
56960
|
scalars;
|
|
56963
56961
|
module = "esm";
|
|
@@ -57009,7 +57007,8 @@ var Config = class {
|
|
|
57009
57007
|
logLevel,
|
|
57010
57008
|
defaultFragmentMasking = "enable",
|
|
57011
57009
|
watchSchema,
|
|
57012
|
-
projectDir
|
|
57010
|
+
projectDir,
|
|
57011
|
+
persistedQueriesPath
|
|
57013
57012
|
} = this.configFile;
|
|
57014
57013
|
if (typeof schema === "string") {
|
|
57015
57014
|
this.schema = graphql.buildSchema(schema);
|
|
@@ -57046,6 +57045,9 @@ var Config = class {
|
|
|
57046
57045
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
57047
57046
|
this.rootDir = join(this.projectRoot, "$houdini");
|
|
57048
57047
|
this.#fragmentVariableMaps = {};
|
|
57048
|
+
if (persistedQueriesPath) {
|
|
57049
|
+
this.persistedQueriesPath = persistedQueriesPath;
|
|
57050
|
+
}
|
|
57049
57051
|
if (defaultKeys) {
|
|
57050
57052
|
this.defaultKeys = defaultKeys;
|
|
57051
57053
|
}
|
|
@@ -57556,11 +57558,14 @@ function getRootType(type) {
|
|
|
57556
57558
|
}
|
|
57557
57559
|
return type;
|
|
57558
57560
|
}
|
|
57559
|
-
function
|
|
57560
|
-
document
|
|
57561
|
-
}
|
|
57562
|
-
|
|
57563
|
-
return
|
|
57561
|
+
function hashOriginal({ document }) {
|
|
57562
|
+
return hashDocument(document.originalString);
|
|
57563
|
+
}
|
|
57564
|
+
function hashRaw({ document }) {
|
|
57565
|
+
return hashDocument(document.artifact?.raw);
|
|
57566
|
+
}
|
|
57567
|
+
function hashDocument(str) {
|
|
57568
|
+
return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
|
|
57564
57569
|
}
|
|
57565
57570
|
function parentField(ancestors) {
|
|
57566
57571
|
return walkParentField([...ancestors].sort(() => -1));
|
|
@@ -58444,6 +58449,42 @@ function inlineFragmentArgs({
|
|
|
58444
58449
|
filepath,
|
|
58445
58450
|
document
|
|
58446
58451
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
58452
|
+
const modifyValue = (node) => {
|
|
58453
|
+
if (node.kind == "ObjectValue") {
|
|
58454
|
+
return {
|
|
58455
|
+
...node,
|
|
58456
|
+
fields: node.fields.map((field) => {
|
|
58457
|
+
const modifiedValue = modifyValue(field.value);
|
|
58458
|
+
if (!modifiedValue)
|
|
58459
|
+
return null;
|
|
58460
|
+
return {
|
|
58461
|
+
...field,
|
|
58462
|
+
value: modifyValue(field.value)
|
|
58463
|
+
};
|
|
58464
|
+
})
|
|
58465
|
+
};
|
|
58466
|
+
}
|
|
58467
|
+
if (node.kind !== "Variable") {
|
|
58468
|
+
return node;
|
|
58469
|
+
}
|
|
58470
|
+
if (!scope) {
|
|
58471
|
+
throw new HoudiniError({
|
|
58472
|
+
filepath,
|
|
58473
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58474
|
+
});
|
|
58475
|
+
}
|
|
58476
|
+
const newValue = scope[node.name.value];
|
|
58477
|
+
if (newValue) {
|
|
58478
|
+
return newValue;
|
|
58479
|
+
}
|
|
58480
|
+
if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
|
|
58481
|
+
throw new HoudiniError({
|
|
58482
|
+
filepath,
|
|
58483
|
+
message: "Missing value for required arg: " + node.name.value
|
|
58484
|
+
});
|
|
58485
|
+
}
|
|
58486
|
+
return null;
|
|
58487
|
+
};
|
|
58447
58488
|
const result = esm_default(
|
|
58448
58489
|
graphql3.visit(document, {
|
|
58449
58490
|
FragmentSpread(node) {
|
|
@@ -58517,29 +58558,14 @@ function inlineFragmentArgs({
|
|
|
58517
58558
|
}
|
|
58518
58559
|
},
|
|
58519
58560
|
Argument(node) {
|
|
58520
|
-
|
|
58521
|
-
|
|
58522
|
-
return;
|
|
58523
|
-
}
|
|
58524
|
-
if (!scope) {
|
|
58525
|
-
throw new HoudiniError({
|
|
58526
|
-
filepath,
|
|
58527
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58528
|
-
});
|
|
58529
|
-
}
|
|
58530
|
-
const newValue = scope[value.name.value];
|
|
58561
|
+
let value = node.value;
|
|
58562
|
+
const newValue = modifyValue(value);
|
|
58531
58563
|
if (newValue) {
|
|
58532
58564
|
return {
|
|
58533
58565
|
...node,
|
|
58534
58566
|
value: newValue
|
|
58535
58567
|
};
|
|
58536
58568
|
}
|
|
58537
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
58538
|
-
throw new HoudiniError({
|
|
58539
|
-
filepath,
|
|
58540
|
-
message: "Missing value for required arg: " + value.name.value
|
|
58541
|
-
});
|
|
58542
|
-
}
|
|
58543
58569
|
return null;
|
|
58544
58570
|
}
|
|
58545
58571
|
})
|
|
@@ -60363,13 +60389,13 @@ function artifactGenerator(stats) {
|
|
|
60363
60389
|
});
|
|
60364
60390
|
}
|
|
60365
60391
|
const listOfArtifacts = [];
|
|
60366
|
-
const
|
|
60392
|
+
const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
|
|
60367
60393
|
await Promise.all(
|
|
60368
60394
|
[
|
|
60369
60395
|
writeIndexFile(config2, docs)
|
|
60370
60396
|
].concat(
|
|
60371
60397
|
docs.map(async (doc) => {
|
|
60372
|
-
const { document, name, generateArtifact, originalParsed
|
|
60398
|
+
const { document, name, generateArtifact, originalParsed } = doc;
|
|
60373
60399
|
if (!generateArtifact) {
|
|
60374
60400
|
return;
|
|
60375
60401
|
}
|
|
@@ -60476,7 +60502,7 @@ function artifactGenerator(stats) {
|
|
|
60476
60502
|
let artifact = {
|
|
60477
60503
|
name,
|
|
60478
60504
|
kind: docKind,
|
|
60479
|
-
hash:
|
|
60505
|
+
hash: "NOT_YET",
|
|
60480
60506
|
refetch: doc.refetch,
|
|
60481
60507
|
raw: rawString,
|
|
60482
60508
|
rootType,
|
|
@@ -60503,6 +60529,8 @@ function artifactGenerator(stats) {
|
|
|
60503
60529
|
}),
|
|
60504
60530
|
pluginData: {}
|
|
60505
60531
|
};
|
|
60532
|
+
const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
|
|
60533
|
+
artifact.hash = hash_value;
|
|
60506
60534
|
applyMask(
|
|
60507
60535
|
config2,
|
|
60508
60536
|
artifact.selection,
|
|
@@ -60577,11 +60605,10 @@ function artifactGenerator(stats) {
|
|
|
60577
60605
|
}
|
|
60578
60606
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
60579
60607
|
}
|
|
60608
|
+
const _houdiniHash = hashOriginal({ document: doc });
|
|
60580
60609
|
const file = AST5.program([
|
|
60581
60610
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
60582
|
-
AST5.expressionStatement(
|
|
60583
|
-
AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
|
|
60584
|
-
)
|
|
60611
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
60585
60612
|
]);
|
|
60586
60613
|
const artifactPath = config2.artifactPath(document);
|
|
60587
60614
|
const countDocument = doc.generateStore;
|
|
@@ -60598,10 +60625,12 @@ function artifactGenerator(stats) {
|
|
|
60598
60625
|
return;
|
|
60599
60626
|
}
|
|
60600
60627
|
const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
|
|
60601
|
-
if (match && match[1] !==
|
|
60628
|
+
if (match && match[1] !== _houdiniHash) {
|
|
60602
60629
|
stats.changed.push(artifact.name);
|
|
60603
60630
|
}
|
|
60604
60631
|
stats.total.push(artifact.name);
|
|
60632
|
+
stats.hashSize.push(artifact.hash.length);
|
|
60633
|
+
stats.querySize.push(artifact.raw.length);
|
|
60605
60634
|
})
|
|
60606
60635
|
)
|
|
60607
60636
|
);
|
|
@@ -62206,39 +62235,36 @@ async function typescriptGenerator(config2, docs) {
|
|
|
62206
62235
|
// src/codegen/generators/persistedQueries/index.ts
|
|
62207
62236
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
62208
62237
|
async function persistOutputGenerator(config2, docs) {
|
|
62209
|
-
if (
|
|
62210
|
-
|
|
62211
|
-
if (!config2.persistedQueryPath.endsWith(".json")) {
|
|
62212
|
-
console.log("Can only write the queryMap to a json file");
|
|
62213
|
-
return;
|
|
62238
|
+
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
62239
|
+
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
62214
62240
|
}
|
|
62215
|
-
const queryMap = docs.reduce(
|
|
62216
|
-
|
|
62217
|
-
|
|
62218
|
-
|
|
62219
|
-
|
|
62220
|
-
|
|
62221
|
-
|
|
62222
|
-
|
|
62223
|
-
|
|
62224
|
-
|
|
62225
|
-
}
|
|
62241
|
+
const queryMap = docs.reduce((acc, doc) => {
|
|
62242
|
+
const { document, generateArtifact, artifact } = doc;
|
|
62243
|
+
if (!generateArtifact) {
|
|
62244
|
+
return acc;
|
|
62245
|
+
}
|
|
62246
|
+
let rawString = graphql18.print(
|
|
62247
|
+
graphql18.visit(document, {
|
|
62248
|
+
Directive(node) {
|
|
62249
|
+
if (config2.isInternalDirective(node.name.value)) {
|
|
62250
|
+
return null;
|
|
62226
62251
|
}
|
|
62227
|
-
}
|
|
62228
|
-
)
|
|
62229
|
-
|
|
62230
|
-
|
|
62231
|
-
)
|
|
62232
|
-
|
|
62233
|
-
|
|
62252
|
+
}
|
|
62253
|
+
})
|
|
62254
|
+
);
|
|
62255
|
+
const operations = document.definitions.filter(
|
|
62256
|
+
({ kind }) => kind === graphql18.Kind.OPERATION_DEFINITION
|
|
62257
|
+
);
|
|
62258
|
+
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
62259
|
+
if (artifact) {
|
|
62260
|
+
acc[artifact.hash] = rawString;
|
|
62234
62261
|
}
|
|
62235
|
-
|
|
62236
|
-
|
|
62237
|
-
|
|
62238
|
-
);
|
|
62262
|
+
}
|
|
62263
|
+
return acc;
|
|
62264
|
+
}, {});
|
|
62239
62265
|
if (Object.keys(queryMap).length === 0)
|
|
62240
62266
|
return;
|
|
62241
|
-
await fs_exports.writeFile(config2.
|
|
62267
|
+
await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
|
|
62242
62268
|
}
|
|
62243
62269
|
|
|
62244
62270
|
// src/codegen/generators/definitions/enums.ts
|
|
@@ -63556,7 +63582,9 @@ async function runPipeline2(config2, docs) {
|
|
|
63556
63582
|
total: [],
|
|
63557
63583
|
changed: [],
|
|
63558
63584
|
new: [],
|
|
63559
|
-
deleted: []
|
|
63585
|
+
deleted: [],
|
|
63586
|
+
hashSize: [],
|
|
63587
|
+
querySize: []
|
|
63560
63588
|
};
|
|
63561
63589
|
const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
|
|
63562
63590
|
const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
|
|
@@ -63569,6 +63597,9 @@ async function runPipeline2(config2, docs) {
|
|
|
63569
63597
|
documents: docs2
|
|
63570
63598
|
})
|
|
63571
63599
|
);
|
|
63600
|
+
if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
|
|
63601
|
+
console.log("\u{1F3A9} Generating runtime...");
|
|
63602
|
+
}
|
|
63572
63603
|
let error = null;
|
|
63573
63604
|
try {
|
|
63574
63605
|
await runPipeline(
|
|
@@ -63615,9 +63646,6 @@ async function runPipeline2(config2, docs) {
|
|
|
63615
63646
|
}
|
|
63616
63647
|
return;
|
|
63617
63648
|
}
|
|
63618
|
-
if (!config2.pluginMode) {
|
|
63619
|
-
console.log("\u{1F3A9} Generating runtime...");
|
|
63620
|
-
}
|
|
63621
63649
|
if (error) {
|
|
63622
63650
|
throw error;
|
|
63623
63651
|
}
|
|
@@ -63642,6 +63670,14 @@ async function runPipeline2(config2, docs) {
|
|
|
63642
63670
|
}
|
|
63643
63671
|
console.log(`${emoji} ${artifact}`);
|
|
63644
63672
|
}
|
|
63673
|
+
console.log(``);
|
|
63674
|
+
console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
|
|
63675
|
+
const format = (val) => {
|
|
63676
|
+
return `${(val / 1024).toFixed(1)} kb`;
|
|
63677
|
+
};
|
|
63678
|
+
const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
|
|
63679
|
+
const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
|
|
63680
|
+
console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
|
|
63645
63681
|
}
|
|
63646
63682
|
}
|
|
63647
63683
|
function logStyled(kind, stat2, logLevel, plugin2) {
|
package/build/test-esm/index.js
CHANGED
|
@@ -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;
|
|
@@ -56952,7 +56950,7 @@ var Config = class {
|
|
|
56952
56950
|
projectRoot;
|
|
56953
56951
|
schema;
|
|
56954
56952
|
schemaPath;
|
|
56955
|
-
|
|
56953
|
+
persistedQueriesPath = "./$houdini/persisted_queries.json";
|
|
56956
56954
|
exclude;
|
|
56957
56955
|
scalars;
|
|
56958
56956
|
module = "esm";
|
|
@@ -57004,7 +57002,8 @@ var Config = class {
|
|
|
57004
57002
|
logLevel,
|
|
57005
57003
|
defaultFragmentMasking = "enable",
|
|
57006
57004
|
watchSchema,
|
|
57007
|
-
projectDir
|
|
57005
|
+
projectDir,
|
|
57006
|
+
persistedQueriesPath
|
|
57008
57007
|
} = this.configFile;
|
|
57009
57008
|
if (typeof schema === "string") {
|
|
57010
57009
|
this.schema = graphql.buildSchema(schema);
|
|
@@ -57041,6 +57040,9 @@ var Config = class {
|
|
|
57041
57040
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
57042
57041
|
this.rootDir = join(this.projectRoot, "$houdini");
|
|
57043
57042
|
this.#fragmentVariableMaps = {};
|
|
57043
|
+
if (persistedQueriesPath) {
|
|
57044
|
+
this.persistedQueriesPath = persistedQueriesPath;
|
|
57045
|
+
}
|
|
57044
57046
|
if (defaultKeys) {
|
|
57045
57047
|
this.defaultKeys = defaultKeys;
|
|
57046
57048
|
}
|
|
@@ -57551,11 +57553,14 @@ function getRootType(type) {
|
|
|
57551
57553
|
}
|
|
57552
57554
|
return type;
|
|
57553
57555
|
}
|
|
57554
|
-
function
|
|
57555
|
-
document
|
|
57556
|
-
}
|
|
57557
|
-
|
|
57558
|
-
return
|
|
57556
|
+
function hashOriginal({ document }) {
|
|
57557
|
+
return hashDocument(document.originalString);
|
|
57558
|
+
}
|
|
57559
|
+
function hashRaw({ document }) {
|
|
57560
|
+
return hashDocument(document.artifact?.raw);
|
|
57561
|
+
}
|
|
57562
|
+
function hashDocument(str) {
|
|
57563
|
+
return crypto.createHash("sha256").update(str || "").digest("hex");
|
|
57559
57564
|
}
|
|
57560
57565
|
function parentField(ancestors) {
|
|
57561
57566
|
return walkParentField([...ancestors].sort(() => -1));
|
|
@@ -58439,6 +58444,42 @@ function inlineFragmentArgs({
|
|
|
58439
58444
|
filepath,
|
|
58440
58445
|
document
|
|
58441
58446
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
58447
|
+
const modifyValue = (node) => {
|
|
58448
|
+
if (node.kind == "ObjectValue") {
|
|
58449
|
+
return {
|
|
58450
|
+
...node,
|
|
58451
|
+
fields: node.fields.map((field) => {
|
|
58452
|
+
const modifiedValue = modifyValue(field.value);
|
|
58453
|
+
if (!modifiedValue)
|
|
58454
|
+
return null;
|
|
58455
|
+
return {
|
|
58456
|
+
...field,
|
|
58457
|
+
value: modifyValue(field.value)
|
|
58458
|
+
};
|
|
58459
|
+
})
|
|
58460
|
+
};
|
|
58461
|
+
}
|
|
58462
|
+
if (node.kind !== "Variable") {
|
|
58463
|
+
return node;
|
|
58464
|
+
}
|
|
58465
|
+
if (!scope) {
|
|
58466
|
+
throw new HoudiniError({
|
|
58467
|
+
filepath,
|
|
58468
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58469
|
+
});
|
|
58470
|
+
}
|
|
58471
|
+
const newValue = scope[node.name.value];
|
|
58472
|
+
if (newValue) {
|
|
58473
|
+
return newValue;
|
|
58474
|
+
}
|
|
58475
|
+
if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
|
|
58476
|
+
throw new HoudiniError({
|
|
58477
|
+
filepath,
|
|
58478
|
+
message: "Missing value for required arg: " + node.name.value
|
|
58479
|
+
});
|
|
58480
|
+
}
|
|
58481
|
+
return null;
|
|
58482
|
+
};
|
|
58442
58483
|
const result = esm_default(
|
|
58443
58484
|
graphql3.visit(document, {
|
|
58444
58485
|
FragmentSpread(node) {
|
|
@@ -58512,29 +58553,14 @@ function inlineFragmentArgs({
|
|
|
58512
58553
|
}
|
|
58513
58554
|
},
|
|
58514
58555
|
Argument(node) {
|
|
58515
|
-
|
|
58516
|
-
|
|
58517
|
-
return;
|
|
58518
|
-
}
|
|
58519
|
-
if (!scope) {
|
|
58520
|
-
throw new HoudiniError({
|
|
58521
|
-
filepath,
|
|
58522
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
58523
|
-
});
|
|
58524
|
-
}
|
|
58525
|
-
const newValue = scope[value.name.value];
|
|
58556
|
+
let value = node.value;
|
|
58557
|
+
const newValue = modifyValue(value);
|
|
58526
58558
|
if (newValue) {
|
|
58527
58559
|
return {
|
|
58528
58560
|
...node,
|
|
58529
58561
|
value: newValue
|
|
58530
58562
|
};
|
|
58531
58563
|
}
|
|
58532
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
58533
|
-
throw new HoudiniError({
|
|
58534
|
-
filepath,
|
|
58535
|
-
message: "Missing value for required arg: " + value.name.value
|
|
58536
|
-
});
|
|
58537
|
-
}
|
|
58538
58564
|
return null;
|
|
58539
58565
|
}
|
|
58540
58566
|
})
|
|
@@ -60358,13 +60384,13 @@ function artifactGenerator(stats) {
|
|
|
60358
60384
|
});
|
|
60359
60385
|
}
|
|
60360
60386
|
const listOfArtifacts = [];
|
|
60361
|
-
const
|
|
60387
|
+
const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
|
|
60362
60388
|
await Promise.all(
|
|
60363
60389
|
[
|
|
60364
60390
|
writeIndexFile(config2, docs)
|
|
60365
60391
|
].concat(
|
|
60366
60392
|
docs.map(async (doc) => {
|
|
60367
|
-
const { document, name, generateArtifact, originalParsed
|
|
60393
|
+
const { document, name, generateArtifact, originalParsed } = doc;
|
|
60368
60394
|
if (!generateArtifact) {
|
|
60369
60395
|
return;
|
|
60370
60396
|
}
|
|
@@ -60471,7 +60497,7 @@ function artifactGenerator(stats) {
|
|
|
60471
60497
|
let artifact = {
|
|
60472
60498
|
name,
|
|
60473
60499
|
kind: docKind,
|
|
60474
|
-
hash:
|
|
60500
|
+
hash: "NOT_YET",
|
|
60475
60501
|
refetch: doc.refetch,
|
|
60476
60502
|
raw: rawString,
|
|
60477
60503
|
rootType,
|
|
@@ -60498,6 +60524,8 @@ function artifactGenerator(stats) {
|
|
|
60498
60524
|
}),
|
|
60499
60525
|
pluginData: {}
|
|
60500
60526
|
};
|
|
60527
|
+
const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
|
|
60528
|
+
artifact.hash = hash_value;
|
|
60501
60529
|
applyMask(
|
|
60502
60530
|
config2,
|
|
60503
60531
|
artifact.selection,
|
|
@@ -60572,11 +60600,10 @@ function artifactGenerator(stats) {
|
|
|
60572
60600
|
}
|
|
60573
60601
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
60574
60602
|
}
|
|
60603
|
+
const _houdiniHash = hashOriginal({ document: doc });
|
|
60575
60604
|
const file = AST5.program([
|
|
60576
60605
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
60577
|
-
AST5.expressionStatement(
|
|
60578
|
-
AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
|
|
60579
|
-
)
|
|
60606
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
60580
60607
|
]);
|
|
60581
60608
|
const artifactPath = config2.artifactPath(document);
|
|
60582
60609
|
const countDocument = doc.generateStore;
|
|
@@ -60593,10 +60620,12 @@ function artifactGenerator(stats) {
|
|
|
60593
60620
|
return;
|
|
60594
60621
|
}
|
|
60595
60622
|
const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
|
|
60596
|
-
if (match && match[1] !==
|
|
60623
|
+
if (match && match[1] !== _houdiniHash) {
|
|
60597
60624
|
stats.changed.push(artifact.name);
|
|
60598
60625
|
}
|
|
60599
60626
|
stats.total.push(artifact.name);
|
|
60627
|
+
stats.hashSize.push(artifact.hash.length);
|
|
60628
|
+
stats.querySize.push(artifact.raw.length);
|
|
60600
60629
|
})
|
|
60601
60630
|
)
|
|
60602
60631
|
);
|
|
@@ -62201,39 +62230,36 @@ async function typescriptGenerator(config2, docs) {
|
|
|
62201
62230
|
// src/codegen/generators/persistedQueries/index.ts
|
|
62202
62231
|
var graphql18 = __toESM(require_graphql2(), 1);
|
|
62203
62232
|
async function persistOutputGenerator(config2, docs) {
|
|
62204
|
-
if (
|
|
62205
|
-
|
|
62206
|
-
if (!config2.persistedQueryPath.endsWith(".json")) {
|
|
62207
|
-
console.log("Can only write the queryMap to a json file");
|
|
62208
|
-
return;
|
|
62233
|
+
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
62234
|
+
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
62209
62235
|
}
|
|
62210
|
-
const queryMap = docs.reduce(
|
|
62211
|
-
|
|
62212
|
-
|
|
62213
|
-
|
|
62214
|
-
|
|
62215
|
-
|
|
62216
|
-
|
|
62217
|
-
|
|
62218
|
-
|
|
62219
|
-
|
|
62220
|
-
}
|
|
62236
|
+
const queryMap = docs.reduce((acc, doc) => {
|
|
62237
|
+
const { document, generateArtifact, artifact } = doc;
|
|
62238
|
+
if (!generateArtifact) {
|
|
62239
|
+
return acc;
|
|
62240
|
+
}
|
|
62241
|
+
let rawString = graphql18.print(
|
|
62242
|
+
graphql18.visit(document, {
|
|
62243
|
+
Directive(node) {
|
|
62244
|
+
if (config2.isInternalDirective(node.name.value)) {
|
|
62245
|
+
return null;
|
|
62221
62246
|
}
|
|
62222
|
-
}
|
|
62223
|
-
)
|
|
62224
|
-
|
|
62225
|
-
|
|
62226
|
-
)
|
|
62227
|
-
|
|
62228
|
-
|
|
62247
|
+
}
|
|
62248
|
+
})
|
|
62249
|
+
);
|
|
62250
|
+
const operations = document.definitions.filter(
|
|
62251
|
+
({ kind }) => kind === graphql18.Kind.OPERATION_DEFINITION
|
|
62252
|
+
);
|
|
62253
|
+
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
62254
|
+
if (artifact) {
|
|
62255
|
+
acc[artifact.hash] = rawString;
|
|
62229
62256
|
}
|
|
62230
|
-
|
|
62231
|
-
|
|
62232
|
-
|
|
62233
|
-
);
|
|
62257
|
+
}
|
|
62258
|
+
return acc;
|
|
62259
|
+
}, {});
|
|
62234
62260
|
if (Object.keys(queryMap).length === 0)
|
|
62235
62261
|
return;
|
|
62236
|
-
await fs_exports.writeFile(config2.
|
|
62262
|
+
await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
|
|
62237
62263
|
}
|
|
62238
62264
|
|
|
62239
62265
|
// src/codegen/generators/definitions/enums.ts
|
|
@@ -63551,7 +63577,9 @@ async function runPipeline2(config2, docs) {
|
|
|
63551
63577
|
total: [],
|
|
63552
63578
|
changed: [],
|
|
63553
63579
|
new: [],
|
|
63554
|
-
deleted: []
|
|
63580
|
+
deleted: [],
|
|
63581
|
+
hashSize: [],
|
|
63582
|
+
querySize: []
|
|
63555
63583
|
};
|
|
63556
63584
|
const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
|
|
63557
63585
|
const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
|
|
@@ -63564,6 +63592,9 @@ async function runPipeline2(config2, docs) {
|
|
|
63564
63592
|
documents: docs2
|
|
63565
63593
|
})
|
|
63566
63594
|
);
|
|
63595
|
+
if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
|
|
63596
|
+
console.log("\u{1F3A9} Generating runtime...");
|
|
63597
|
+
}
|
|
63567
63598
|
let error = null;
|
|
63568
63599
|
try {
|
|
63569
63600
|
await runPipeline(
|
|
@@ -63610,9 +63641,6 @@ async function runPipeline2(config2, docs) {
|
|
|
63610
63641
|
}
|
|
63611
63642
|
return;
|
|
63612
63643
|
}
|
|
63613
|
-
if (!config2.pluginMode) {
|
|
63614
|
-
console.log("\u{1F3A9} Generating runtime...");
|
|
63615
|
-
}
|
|
63616
63644
|
if (error) {
|
|
63617
63645
|
throw error;
|
|
63618
63646
|
}
|
|
@@ -63637,6 +63665,14 @@ async function runPipeline2(config2, docs) {
|
|
|
63637
63665
|
}
|
|
63638
63666
|
console.log(`${emoji} ${artifact}`);
|
|
63639
63667
|
}
|
|
63668
|
+
console.log(``);
|
|
63669
|
+
console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
|
|
63670
|
+
const format = (val) => {
|
|
63671
|
+
return `${(val / 1024).toFixed(1)} kb`;
|
|
63672
|
+
};
|
|
63673
|
+
const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
|
|
63674
|
+
const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
|
|
63675
|
+
console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
|
|
63640
63676
|
}
|
|
63641
63677
|
}
|
|
63642
63678
|
function logStyled(kind, stat2, logLevel, plugin2) {
|