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-cjs/index.js
CHANGED
|
@@ -71697,12 +71697,9 @@ var CacheInternal = class {
|
|
|
71697
71697
|
);
|
|
71698
71698
|
}
|
|
71699
71699
|
}
|
|
71700
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
71701
|
-
(field2) => typeof value[field2] === "undefined"
|
|
71702
|
-
).length > 0;
|
|
71703
71700
|
let linkedID = null;
|
|
71704
71701
|
if (value !== null) {
|
|
71705
|
-
linkedID = !
|
|
71702
|
+
linkedID = !this.isEmbedded(linkedType, value) ? this.id(linkedType, value) : `${parent2}.${key}`;
|
|
71706
71703
|
}
|
|
71707
71704
|
let linkChange = linkedID !== previousValue;
|
|
71708
71705
|
layer.writeLink(parent2, key, linkedID);
|
|
@@ -72074,6 +72071,10 @@ var CacheInternal = class {
|
|
|
72074
72071
|
computeID(type, data) {
|
|
72075
72072
|
return computeID(this.config, type, data);
|
|
72076
72073
|
}
|
|
72074
|
+
isEmbedded(linkedType, value) {
|
|
72075
|
+
const idFields = this.idFields(linkedType);
|
|
72076
|
+
return idFields.length === 0 || idFields.filter((field) => typeof value[field] === "undefined").length > 0;
|
|
72077
|
+
}
|
|
72077
72078
|
hydrateNestedList({
|
|
72078
72079
|
fields,
|
|
72079
72080
|
variables,
|
|
@@ -72181,9 +72182,6 @@ var CacheInternal = class {
|
|
|
72181
72182
|
}
|
|
72182
72183
|
const entryObj = entry;
|
|
72183
72184
|
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
72184
|
-
const embedded = this.idFields(linkedType)?.filter(
|
|
72185
|
-
(field) => typeof entry[field] === "undefined"
|
|
72186
|
-
).length > 0;
|
|
72187
72185
|
let innerType = linkedType;
|
|
72188
72186
|
const typename = entryObj.__typename;
|
|
72189
72187
|
if (typename) {
|
|
@@ -72191,7 +72189,7 @@ var CacheInternal = class {
|
|
|
72191
72189
|
} else if (abstract) {
|
|
72192
72190
|
throw new Error("Encountered interface type without __typename in the payload");
|
|
72193
72191
|
}
|
|
72194
|
-
if (!
|
|
72192
|
+
if (!this.isEmbedded(linkedType, entry)) {
|
|
72195
72193
|
const id = this.id(innerType, entry);
|
|
72196
72194
|
if (id) {
|
|
72197
72195
|
linkedID = id;
|
|
@@ -72475,7 +72473,7 @@ var Config = class {
|
|
|
72475
72473
|
projectRoot;
|
|
72476
72474
|
schema;
|
|
72477
72475
|
schemaPath;
|
|
72478
|
-
|
|
72476
|
+
persistedQueriesPath = "./$houdini/persisted_queries.json";
|
|
72479
72477
|
exclude;
|
|
72480
72478
|
scalars;
|
|
72481
72479
|
module = "esm";
|
|
@@ -72527,7 +72525,8 @@ var Config = class {
|
|
|
72527
72525
|
logLevel,
|
|
72528
72526
|
defaultFragmentMasking = "enable",
|
|
72529
72527
|
watchSchema,
|
|
72530
|
-
projectDir
|
|
72528
|
+
projectDir,
|
|
72529
|
+
persistedQueriesPath
|
|
72531
72530
|
} = this.configFile;
|
|
72532
72531
|
if (typeof schema === "string") {
|
|
72533
72532
|
this.schema = graphql2.buildSchema(schema);
|
|
@@ -72564,6 +72563,9 @@ var Config = class {
|
|
|
72564
72563
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
72565
72564
|
this.rootDir = join2(this.projectRoot, "$houdini");
|
|
72566
72565
|
this.#fragmentVariableMaps = {};
|
|
72566
|
+
if (persistedQueriesPath) {
|
|
72567
|
+
this.persistedQueriesPath = persistedQueriesPath;
|
|
72568
|
+
}
|
|
72567
72569
|
if (defaultKeys) {
|
|
72568
72570
|
this.defaultKeys = defaultKeys;
|
|
72569
72571
|
}
|
|
@@ -73278,11 +73280,14 @@ function getRootType(type) {
|
|
|
73278
73280
|
}
|
|
73279
73281
|
return type;
|
|
73280
73282
|
}
|
|
73281
|
-
function
|
|
73282
|
-
document
|
|
73283
|
-
}
|
|
73284
|
-
|
|
73285
|
-
return
|
|
73283
|
+
function hashOriginal({ document }) {
|
|
73284
|
+
return hashDocument(document.originalString);
|
|
73285
|
+
}
|
|
73286
|
+
function hashRaw({ document }) {
|
|
73287
|
+
return hashDocument(document.artifact?.raw);
|
|
73288
|
+
}
|
|
73289
|
+
function hashDocument(str) {
|
|
73290
|
+
return import_node_crypto.default.createHash("sha256").update(str || "").digest("hex");
|
|
73286
73291
|
}
|
|
73287
73292
|
function parentField(ancestors) {
|
|
73288
73293
|
return walkParentField([...ancestors].sort(() => -1));
|
|
@@ -74426,6 +74431,42 @@ function inlineFragmentArgs({
|
|
|
74426
74431
|
filepath,
|
|
74427
74432
|
document
|
|
74428
74433
|
).reduce((acc, arg) => ({ ...acc, [arg.name]: arg }), {});
|
|
74434
|
+
const modifyValue = (node) => {
|
|
74435
|
+
if (node.kind == "ObjectValue") {
|
|
74436
|
+
return {
|
|
74437
|
+
...node,
|
|
74438
|
+
fields: node.fields.map((field) => {
|
|
74439
|
+
const modifiedValue = modifyValue(field.value);
|
|
74440
|
+
if (!modifiedValue)
|
|
74441
|
+
return null;
|
|
74442
|
+
return {
|
|
74443
|
+
...field,
|
|
74444
|
+
value: modifyValue(field.value)
|
|
74445
|
+
};
|
|
74446
|
+
})
|
|
74447
|
+
};
|
|
74448
|
+
}
|
|
74449
|
+
if (node.kind !== "Variable") {
|
|
74450
|
+
return node;
|
|
74451
|
+
}
|
|
74452
|
+
if (!scope) {
|
|
74453
|
+
throw new HoudiniError({
|
|
74454
|
+
filepath,
|
|
74455
|
+
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
74456
|
+
});
|
|
74457
|
+
}
|
|
74458
|
+
const newValue = scope[node.name.value];
|
|
74459
|
+
if (newValue) {
|
|
74460
|
+
return newValue;
|
|
74461
|
+
}
|
|
74462
|
+
if (definitionArgs[node.name.value] && definitionArgs[node.name.value].required) {
|
|
74463
|
+
throw new HoudiniError({
|
|
74464
|
+
filepath,
|
|
74465
|
+
message: "Missing value for required arg: " + node.name.value
|
|
74466
|
+
});
|
|
74467
|
+
}
|
|
74468
|
+
return null;
|
|
74469
|
+
};
|
|
74429
74470
|
const result = esm_default(
|
|
74430
74471
|
graphql5.visit(document, {
|
|
74431
74472
|
FragmentSpread(node) {
|
|
@@ -74499,29 +74540,14 @@ function inlineFragmentArgs({
|
|
|
74499
74540
|
}
|
|
74500
74541
|
},
|
|
74501
74542
|
Argument(node) {
|
|
74502
|
-
|
|
74503
|
-
|
|
74504
|
-
return;
|
|
74505
|
-
}
|
|
74506
|
-
if (!scope) {
|
|
74507
|
-
throw new HoudiniError({
|
|
74508
|
-
filepath,
|
|
74509
|
-
message: node.name.value + " is not defined in the current scope: " + JSON.stringify(scope)
|
|
74510
|
-
});
|
|
74511
|
-
}
|
|
74512
|
-
const newValue = scope[value.name.value];
|
|
74543
|
+
let value = node.value;
|
|
74544
|
+
const newValue = modifyValue(value);
|
|
74513
74545
|
if (newValue) {
|
|
74514
74546
|
return {
|
|
74515
74547
|
...node,
|
|
74516
74548
|
value: newValue
|
|
74517
74549
|
};
|
|
74518
74550
|
}
|
|
74519
|
-
if (definitionArgs[value.name.value] && definitionArgs[value.name.value].required) {
|
|
74520
|
-
throw new HoudiniError({
|
|
74521
|
-
filepath,
|
|
74522
|
-
message: "Missing value for required arg: " + value.name.value
|
|
74523
|
-
});
|
|
74524
|
-
}
|
|
74525
74551
|
return null;
|
|
74526
74552
|
}
|
|
74527
74553
|
})
|
|
@@ -76345,13 +76371,13 @@ function artifactGenerator(stats) {
|
|
|
76345
76371
|
});
|
|
76346
76372
|
}
|
|
76347
76373
|
const listOfArtifacts = [];
|
|
76348
|
-
const
|
|
76374
|
+
const hashPluginBaseRaw = config2.plugins?.find((plugin2) => plugin2.hash)?.hash ?? hashRaw;
|
|
76349
76375
|
await Promise.all(
|
|
76350
76376
|
[
|
|
76351
76377
|
writeIndexFile(config2, docs)
|
|
76352
76378
|
].concat(
|
|
76353
76379
|
docs.map(async (doc) => {
|
|
76354
|
-
const { document, name, generateArtifact, originalParsed
|
|
76380
|
+
const { document, name, generateArtifact, originalParsed } = doc;
|
|
76355
76381
|
if (!generateArtifact) {
|
|
76356
76382
|
return;
|
|
76357
76383
|
}
|
|
@@ -76458,7 +76484,7 @@ function artifactGenerator(stats) {
|
|
|
76458
76484
|
let artifact = {
|
|
76459
76485
|
name,
|
|
76460
76486
|
kind: docKind,
|
|
76461
|
-
hash:
|
|
76487
|
+
hash: "NOT_YET",
|
|
76462
76488
|
refetch: doc.refetch,
|
|
76463
76489
|
raw: rawString,
|
|
76464
76490
|
rootType,
|
|
@@ -76485,6 +76511,8 @@ function artifactGenerator(stats) {
|
|
|
76485
76511
|
}),
|
|
76486
76512
|
pluginData: {}
|
|
76487
76513
|
};
|
|
76514
|
+
const hash_value = hashPluginBaseRaw({ config: config2, document: { ...doc, artifact } });
|
|
76515
|
+
artifact.hash = hash_value;
|
|
76488
76516
|
applyMask(
|
|
76489
76517
|
config2,
|
|
76490
76518
|
artifact.selection,
|
|
@@ -76559,11 +76587,10 @@ function artifactGenerator(stats) {
|
|
|
76559
76587
|
}
|
|
76560
76588
|
plugin2.artifactEnd({ config: config2, document: doc });
|
|
76561
76589
|
}
|
|
76590
|
+
const _houdiniHash = hashOriginal({ document: doc });
|
|
76562
76591
|
const file = AST5.program([
|
|
76563
76592
|
moduleExport(config2, "default", serializeValue(artifact)),
|
|
76564
|
-
AST5.expressionStatement(
|
|
76565
|
-
AST5.stringLiteral(`HoudiniHash=${hash({ config: config2, document: doc })}`)
|
|
76566
|
-
)
|
|
76593
|
+
AST5.expressionStatement(AST5.stringLiteral(`HoudiniHash=${_houdiniHash}`))
|
|
76567
76594
|
]);
|
|
76568
76595
|
const artifactPath = config2.artifactPath(document);
|
|
76569
76596
|
const countDocument = doc.generateStore;
|
|
@@ -76580,10 +76607,12 @@ function artifactGenerator(stats) {
|
|
|
76580
76607
|
return;
|
|
76581
76608
|
}
|
|
76582
76609
|
const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
|
|
76583
|
-
if (match && match[1] !==
|
|
76610
|
+
if (match && match[1] !== _houdiniHash) {
|
|
76584
76611
|
stats.changed.push(artifact.name);
|
|
76585
76612
|
}
|
|
76586
76613
|
stats.total.push(artifact.name);
|
|
76614
|
+
stats.hashSize.push(artifact.hash.length);
|
|
76615
|
+
stats.querySize.push(artifact.raw.length);
|
|
76587
76616
|
})
|
|
76588
76617
|
)
|
|
76589
76618
|
);
|
|
@@ -78188,39 +78217,36 @@ async function typescriptGenerator(config2, docs) {
|
|
|
78188
78217
|
// src/codegen/generators/persistedQueries/index.ts
|
|
78189
78218
|
var graphql20 = __toESM(require_graphql2(), 1);
|
|
78190
78219
|
async function persistOutputGenerator(config2, docs) {
|
|
78191
|
-
if (
|
|
78192
|
-
|
|
78193
|
-
if (!config2.persistedQueryPath.endsWith(".json")) {
|
|
78194
|
-
console.log("Can only write the queryMap to a json file");
|
|
78195
|
-
return;
|
|
78220
|
+
if (!config2.persistedQueriesPath.endsWith(".json")) {
|
|
78221
|
+
throw new Error('Can write Persisted Queries only in a ".json" file.');
|
|
78196
78222
|
}
|
|
78197
|
-
const queryMap = docs.reduce(
|
|
78198
|
-
|
|
78199
|
-
|
|
78200
|
-
|
|
78201
|
-
|
|
78202
|
-
|
|
78203
|
-
|
|
78204
|
-
|
|
78205
|
-
|
|
78206
|
-
|
|
78207
|
-
}
|
|
78223
|
+
const queryMap = docs.reduce((acc, doc) => {
|
|
78224
|
+
const { document, generateArtifact, artifact } = doc;
|
|
78225
|
+
if (!generateArtifact) {
|
|
78226
|
+
return acc;
|
|
78227
|
+
}
|
|
78228
|
+
let rawString = graphql20.print(
|
|
78229
|
+
graphql20.visit(document, {
|
|
78230
|
+
Directive(node) {
|
|
78231
|
+
if (config2.isInternalDirective(node.name.value)) {
|
|
78232
|
+
return null;
|
|
78208
78233
|
}
|
|
78209
|
-
}
|
|
78210
|
-
)
|
|
78211
|
-
|
|
78212
|
-
|
|
78213
|
-
)
|
|
78214
|
-
|
|
78215
|
-
|
|
78234
|
+
}
|
|
78235
|
+
})
|
|
78236
|
+
);
|
|
78237
|
+
const operations = document.definitions.filter(
|
|
78238
|
+
({ kind }) => kind === graphql20.Kind.OPERATION_DEFINITION
|
|
78239
|
+
);
|
|
78240
|
+
if (operations.length > 0 && operations[0].kind === "OperationDefinition") {
|
|
78241
|
+
if (artifact) {
|
|
78242
|
+
acc[artifact.hash] = rawString;
|
|
78216
78243
|
}
|
|
78217
|
-
|
|
78218
|
-
|
|
78219
|
-
|
|
78220
|
-
);
|
|
78244
|
+
}
|
|
78245
|
+
return acc;
|
|
78246
|
+
}, {});
|
|
78221
78247
|
if (Object.keys(queryMap).length === 0)
|
|
78222
78248
|
return;
|
|
78223
|
-
await fs_exports.writeFile(config2.
|
|
78249
|
+
await fs_exports.writeFile(config2.persistedQueriesPath, JSON.stringify(queryMap, null, 4));
|
|
78224
78250
|
}
|
|
78225
78251
|
|
|
78226
78252
|
// src/codegen/generators/definitions/enums.ts
|
|
@@ -79542,7 +79568,9 @@ async function runPipeline2(config2, docs) {
|
|
|
79542
79568
|
total: [],
|
|
79543
79569
|
changed: [],
|
|
79544
79570
|
new: [],
|
|
79545
|
-
deleted: []
|
|
79571
|
+
deleted: [],
|
|
79572
|
+
hashSize: [],
|
|
79573
|
+
querySize: []
|
|
79546
79574
|
};
|
|
79547
79575
|
const generatePlugins = config2.plugins.filter((plugin2) => plugin2.generate);
|
|
79548
79576
|
const afterValidate = config2.plugins.filter((plugin2) => plugin2.afterValidate).map((plugin2) => plugin2.afterValidate);
|
|
@@ -79555,6 +79583,9 @@ async function runPipeline2(config2, docs) {
|
|
|
79555
79583
|
documents: docs2
|
|
79556
79584
|
})
|
|
79557
79585
|
);
|
|
79586
|
+
if (!config2.pluginMode && process.env.HOUDINI_TEST !== "true") {
|
|
79587
|
+
console.log("\u{1F3A9} Generating runtime...");
|
|
79588
|
+
}
|
|
79558
79589
|
let error = null;
|
|
79559
79590
|
try {
|
|
79560
79591
|
await runPipeline(
|
|
@@ -79601,9 +79632,6 @@ async function runPipeline2(config2, docs) {
|
|
|
79601
79632
|
}
|
|
79602
79633
|
return;
|
|
79603
79634
|
}
|
|
79604
|
-
if (!config2.pluginMode) {
|
|
79605
|
-
console.log("\u{1F3A9} Generating runtime...");
|
|
79606
|
-
}
|
|
79607
79635
|
if (error) {
|
|
79608
79636
|
throw error;
|
|
79609
79637
|
}
|
|
@@ -79628,6 +79656,14 @@ async function runPipeline2(config2, docs) {
|
|
|
79628
79656
|
}
|
|
79629
79657
|
console.log(`${emoji} ${artifact}`);
|
|
79630
79658
|
}
|
|
79659
|
+
console.log(``);
|
|
79660
|
+
console.log(`\u{1FA84} Total: ${artifactStats.total.length}`);
|
|
79661
|
+
const format = (val) => {
|
|
79662
|
+
return `${(val / 1024).toFixed(1)} kb`;
|
|
79663
|
+
};
|
|
79664
|
+
const hashSize = format(artifactStats.hashSize.reduce((acc, val) => acc + val, 0));
|
|
79665
|
+
const querySize = format(artifactStats.querySize.reduce((acc, val) => acc + val, 0));
|
|
79666
|
+
console.log(`\u{1FAB6} Network request size: ${querySize} (pesisted: ${hashSize})`);
|
|
79631
79667
|
}
|
|
79632
79668
|
}
|
|
79633
79669
|
async function collectDocuments(config2) {
|
|
@@ -79840,7 +79876,7 @@ async function generate(args = {
|
|
|
79840
79876
|
try {
|
|
79841
79877
|
config2 = await getConfig(extraConfig);
|
|
79842
79878
|
if (args.output) {
|
|
79843
|
-
config2.
|
|
79879
|
+
config2.persistedQueriesPath = args.output;
|
|
79844
79880
|
}
|
|
79845
79881
|
if (args.pullSchema && await config2.apiURL()) {
|
|
79846
79882
|
await pullSchema_default(args);
|
|
@@ -80229,8 +80265,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
80229
80265
|
}
|
|
80230
80266
|
packageJSON.devDependencies = {
|
|
80231
80267
|
...packageJSON.devDependencies,
|
|
80232
|
-
houdini: "^1.2.
|
|
80233
|
-
"houdini-svelte": "^1.2.
|
|
80268
|
+
houdini: "^1.2.7",
|
|
80269
|
+
"houdini-svelte": "^1.2.7"
|
|
80234
80270
|
};
|
|
80235
80271
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
80236
80272
|
}
|