houdini 2.0.0-next.0 → 2.0.0-next.2
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 +127 -43
- package/build/cmd-esm/index.js +127 -43
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +3 -0
- package/build/codegen-cjs/index.js +86 -29
- package/build/codegen-esm/index.js +86 -29
- package/build/lib/config.d.ts +3 -0
- package/build/lib/introspection.d.ts +1 -1
- package/build/lib-cjs/index.js +75 -38
- package/build/lib-esm/index.js +75 -38
- package/build/runtime/lib/config.d.ts +7 -0
- package/build/runtime-cjs/cache/cache.js +36 -29
- package/build/runtime-cjs/lib/config.d.ts +7 -0
- package/build/runtime-esm/cache/cache.js +36 -29
- package/build/runtime-esm/lib/config.d.ts +7 -0
- package/build/test-cjs/index.js +64 -32
- package/build/test-esm/index.js +64 -32
- package/build/vite-cjs/index.js +127 -39
- package/build/vite-esm/index.js +127 -39
- package/package.json +1 -1
package/build/lib-esm/index.js
CHANGED
|
@@ -72642,7 +72642,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
72642
72642
|
}
|
|
72643
72643
|
|
|
72644
72644
|
// src/lib/introspection.ts
|
|
72645
|
-
async function pullSchema(url, fetchTimeout, schemaPath, headers,
|
|
72645
|
+
async function pullSchema(url, fetchTimeout, schemaPath, headers, writeToDisk = true) {
|
|
72646
72646
|
let content = "";
|
|
72647
72647
|
try {
|
|
72648
72648
|
const fetchWithTimeout = (url2, timeoutMs, options) => {
|
|
@@ -72680,8 +72680,15 @@ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
|
|
|
72680
72680
|
} else {
|
|
72681
72681
|
fileData = JSON.stringify(jsonSchema);
|
|
72682
72682
|
}
|
|
72683
|
-
if (
|
|
72684
|
-
|
|
72683
|
+
if (writeToDisk) {
|
|
72684
|
+
try {
|
|
72685
|
+
await writeFile(schemaPath, fileData);
|
|
72686
|
+
} catch (e2) {
|
|
72687
|
+
console.warn(
|
|
72688
|
+
`\u26A0\uFE0F Couldn't write your pulled schema to disk: ${e2.message}
|
|
72689
|
+
If this is expected, please set watchSchema.writePolledSchema to false in your config file.`
|
|
72690
|
+
);
|
|
72691
|
+
}
|
|
72685
72692
|
}
|
|
72686
72693
|
return fileData;
|
|
72687
72694
|
} catch (e2) {
|
|
@@ -75282,20 +75289,21 @@ var CacheInternal = class {
|
|
|
75282
75289
|
} else if (Array.isArray(value) && // make typescript happy
|
|
75283
75290
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
75284
75291
|
let oldIDs = [...previousValue || []];
|
|
75285
|
-
|
|
75286
|
-
|
|
75287
|
-
|
|
75288
|
-
|
|
75289
|
-
|
|
75290
|
-
|
|
75291
|
-
|
|
75292
|
-
|
|
75293
|
-
|
|
75294
|
-
|
|
75295
|
-
|
|
75296
|
-
|
|
75297
|
-
|
|
75298
|
-
|
|
75292
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
75293
|
+
oldIDs = oldIDs.filter((id) => {
|
|
75294
|
+
for (const layer2 of this.storage.data) {
|
|
75295
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
75296
|
+
if (operation.fields?.[key])
|
|
75297
|
+
for (const listOperation of operation.fields[key]) {
|
|
75298
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
75299
|
+
return false;
|
|
75300
|
+
}
|
|
75301
|
+
}
|
|
75302
|
+
}
|
|
75303
|
+
}
|
|
75304
|
+
return true;
|
|
75305
|
+
});
|
|
75306
|
+
}
|
|
75299
75307
|
let linkedIDs = [];
|
|
75300
75308
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
75301
75309
|
value,
|
|
@@ -75314,39 +75322,45 @@ var CacheInternal = class {
|
|
|
75314
75322
|
layer.writeLink(parent, key, linkedIDs);
|
|
75315
75323
|
};
|
|
75316
75324
|
if (applyUpdates && updates) {
|
|
75317
|
-
|
|
75318
|
-
const
|
|
75319
|
-
for (const id of
|
|
75325
|
+
const filterIDs = (keep, insert) => {
|
|
75326
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
75327
|
+
for (const id of keep) {
|
|
75320
75328
|
if (!id) {
|
|
75321
75329
|
continue;
|
|
75322
75330
|
}
|
|
75323
75331
|
const { value: node } = this.storage.get(id, "node");
|
|
75324
|
-
if (
|
|
75332
|
+
if (!node) {
|
|
75325
75333
|
continue;
|
|
75326
75334
|
}
|
|
75327
|
-
|
|
75335
|
+
const nodeID = this.storage.get(node, "id");
|
|
75336
|
+
if (!nodeID) {
|
|
75328
75337
|
continue;
|
|
75329
75338
|
}
|
|
75330
|
-
|
|
75339
|
+
existingIDs.add(nodeID.value);
|
|
75331
75340
|
}
|
|
75332
|
-
|
|
75341
|
+
return insert.filter((id) => {
|
|
75333
75342
|
if (!id) {
|
|
75334
75343
|
return true;
|
|
75335
75344
|
}
|
|
75336
|
-
const { value:
|
|
75337
|
-
|
|
75338
|
-
|
|
75339
|
-
return false;
|
|
75345
|
+
const { value: node } = this.storage.get(id, "node");
|
|
75346
|
+
if (!node) {
|
|
75347
|
+
return true;
|
|
75340
75348
|
}
|
|
75341
|
-
|
|
75349
|
+
const nodeID = this.storage.get(node, "id");
|
|
75350
|
+
if (!nodeID) {
|
|
75351
|
+
return true;
|
|
75352
|
+
}
|
|
75353
|
+
return !existingIDs.has(nodeID.value);
|
|
75342
75354
|
});
|
|
75343
|
-
}
|
|
75355
|
+
};
|
|
75344
75356
|
for (const update of applyUpdates) {
|
|
75345
75357
|
if (update !== "replace" && !updates.includes(update)) {
|
|
75346
75358
|
continue;
|
|
75347
75359
|
}
|
|
75348
75360
|
if (update === "prepend") {
|
|
75349
|
-
linkedIDs = newIDs.concat(
|
|
75361
|
+
linkedIDs = newIDs.concat(
|
|
75362
|
+
filterIDs(newIDs, oldIDs)
|
|
75363
|
+
);
|
|
75350
75364
|
if (layer?.optimistic) {
|
|
75351
75365
|
action = () => {
|
|
75352
75366
|
for (const id of newIDs) {
|
|
@@ -75357,7 +75371,7 @@ var CacheInternal = class {
|
|
|
75357
75371
|
};
|
|
75358
75372
|
}
|
|
75359
75373
|
} else if (update === "append") {
|
|
75360
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
75374
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
75361
75375
|
if (layer?.optimistic) {
|
|
75362
75376
|
action = () => {
|
|
75363
75377
|
for (const id of newIDs) {
|
|
@@ -77748,6 +77762,7 @@ var Config = class {
|
|
|
77748
77762
|
routesDir;
|
|
77749
77763
|
schemaPollInterval;
|
|
77750
77764
|
schemaPollTimeout;
|
|
77765
|
+
schemaPollWriteToDisk = false;
|
|
77751
77766
|
schemaPollHeaders;
|
|
77752
77767
|
pluginMode = false;
|
|
77753
77768
|
plugins = [];
|
|
@@ -77824,6 +77839,7 @@ var Config = class {
|
|
|
77824
77839
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
77825
77840
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
77826
77841
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
77842
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
77827
77843
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
77828
77844
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
77829
77845
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -77856,11 +77872,17 @@ var Config = class {
|
|
|
77856
77872
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
77857
77873
|
for (const plugin2 of this.plugins) {
|
|
77858
77874
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
77859
|
-
|
|
77875
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
77876
|
+
if (!runtimeDir && !staticDir) {
|
|
77860
77877
|
continue;
|
|
77861
77878
|
}
|
|
77862
|
-
const
|
|
77863
|
-
|
|
77879
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
77880
|
+
if (!dir) {
|
|
77881
|
+
continue;
|
|
77882
|
+
}
|
|
77883
|
+
const includePath = relative(this.projectRoot, dir);
|
|
77884
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
77885
|
+
}
|
|
77864
77886
|
}
|
|
77865
77887
|
return include;
|
|
77866
77888
|
}
|
|
@@ -77914,6 +77936,15 @@ var Config = class {
|
|
|
77914
77936
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
77915
77937
|
);
|
|
77916
77938
|
}
|
|
77939
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
77940
|
+
if (!plugin2.staticRuntime) {
|
|
77941
|
+
return null;
|
|
77942
|
+
}
|
|
77943
|
+
return join2(
|
|
77944
|
+
dirname(plugin2.filepath),
|
|
77945
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
77946
|
+
);
|
|
77947
|
+
}
|
|
77917
77948
|
async sourceFiles() {
|
|
77918
77949
|
return [
|
|
77919
77950
|
...new Set(
|
|
@@ -78110,6 +78141,9 @@ var Config = class {
|
|
|
78110
78141
|
pluginRuntimeDirectory(name) {
|
|
78111
78142
|
return join2(this.pluginDirectory(name), "runtime");
|
|
78112
78143
|
}
|
|
78144
|
+
pluginStaticRuntimeDirectory(name) {
|
|
78145
|
+
return join2(this.pluginDirectory(name), "static");
|
|
78146
|
+
}
|
|
78113
78147
|
get pluginRootDirectory() {
|
|
78114
78148
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
78115
78149
|
}
|
|
@@ -78487,17 +78521,20 @@ async function getConfig({
|
|
|
78487
78521
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
78488
78522
|
let schemaOk = true;
|
|
78489
78523
|
if (apiURL) {
|
|
78490
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
78524
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
78491
78525
|
console.log(
|
|
78492
78526
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
78493
|
-
This will prevent your schema from being
|
|
78527
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
78494
78528
|
);
|
|
78529
|
+
_config.schemaPollWriteToDisk = false;
|
|
78495
78530
|
} else if (!await readFile(_config.schemaPath)) {
|
|
78496
78531
|
console.log("\u231B Pulling schema from api");
|
|
78497
78532
|
schemaOk = await pullSchema(
|
|
78498
78533
|
apiURL,
|
|
78499
78534
|
_config.schemaPollTimeout,
|
|
78500
|
-
_config.schemaPath
|
|
78535
|
+
_config.schemaPath,
|
|
78536
|
+
{},
|
|
78537
|
+
_config.schemaPollWriteToDisk
|
|
78501
78538
|
) !== null;
|
|
78502
78539
|
}
|
|
78503
78540
|
}
|
|
@@ -196,6 +196,13 @@ export type WatchSchemaConfig = {
|
|
|
196
196
|
* logic you need
|
|
197
197
|
*/
|
|
198
198
|
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
199
|
+
/**
|
|
200
|
+
* Write the schema to disk on pull.
|
|
201
|
+
* Useful for IDE integration.
|
|
202
|
+
* Set to false when you have read only access to the schema or directory it's in.
|
|
203
|
+
* Defaults to true
|
|
204
|
+
*/
|
|
205
|
+
writePolledSchema?: boolean;
|
|
199
206
|
};
|
|
200
207
|
export type ScalarSpec = {
|
|
201
208
|
type: string;
|
|
@@ -414,20 +414,21 @@ class CacheInternal {
|
|
|
414
414
|
} else if (Array.isArray(value) && // make typescript happy
|
|
415
415
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
416
416
|
let oldIDs = [...previousValue || []];
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
417
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
418
|
+
oldIDs = oldIDs.filter((id) => {
|
|
419
|
+
for (const layer2 of this.storage.data) {
|
|
420
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
421
|
+
if (operation.fields?.[key])
|
|
422
|
+
for (const listOperation of operation.fields[key]) {
|
|
423
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return true;
|
|
430
|
+
});
|
|
431
|
+
}
|
|
431
432
|
let linkedIDs = [];
|
|
432
433
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
433
434
|
value,
|
|
@@ -446,39 +447,45 @@ class CacheInternal {
|
|
|
446
447
|
layer.writeLink(parent, key, linkedIDs);
|
|
447
448
|
};
|
|
448
449
|
if (applyUpdates && updates) {
|
|
449
|
-
|
|
450
|
-
const
|
|
451
|
-
for (const id of
|
|
450
|
+
const filterIDs = (keep, insert) => {
|
|
451
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
452
|
+
for (const id of keep) {
|
|
452
453
|
if (!id) {
|
|
453
454
|
continue;
|
|
454
455
|
}
|
|
455
456
|
const { value: node } = this.storage.get(id, "node");
|
|
456
|
-
if (
|
|
457
|
+
if (!node) {
|
|
457
458
|
continue;
|
|
458
459
|
}
|
|
459
|
-
|
|
460
|
+
const nodeID = this.storage.get(node, "id");
|
|
461
|
+
if (!nodeID) {
|
|
460
462
|
continue;
|
|
461
463
|
}
|
|
462
|
-
|
|
464
|
+
existingIDs.add(nodeID.value);
|
|
463
465
|
}
|
|
464
|
-
|
|
466
|
+
return insert.filter((id) => {
|
|
465
467
|
if (!id) {
|
|
466
468
|
return true;
|
|
467
469
|
}
|
|
468
|
-
const { value:
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
const { value: node } = this.storage.get(id, "node");
|
|
471
|
+
if (!node) {
|
|
472
|
+
return true;
|
|
473
|
+
}
|
|
474
|
+
const nodeID = this.storage.get(node, "id");
|
|
475
|
+
if (!nodeID) {
|
|
476
|
+
return true;
|
|
472
477
|
}
|
|
473
|
-
return
|
|
478
|
+
return !existingIDs.has(nodeID.value);
|
|
474
479
|
});
|
|
475
|
-
}
|
|
480
|
+
};
|
|
476
481
|
for (const update of applyUpdates) {
|
|
477
482
|
if (update !== "replace" && !updates.includes(update)) {
|
|
478
483
|
continue;
|
|
479
484
|
}
|
|
480
485
|
if (update === "prepend") {
|
|
481
|
-
linkedIDs = newIDs.concat(
|
|
486
|
+
linkedIDs = newIDs.concat(
|
|
487
|
+
filterIDs(newIDs, oldIDs)
|
|
488
|
+
);
|
|
482
489
|
if (layer?.optimistic) {
|
|
483
490
|
action = () => {
|
|
484
491
|
for (const id of newIDs) {
|
|
@@ -489,7 +496,7 @@ class CacheInternal {
|
|
|
489
496
|
};
|
|
490
497
|
}
|
|
491
498
|
} else if (update === "append") {
|
|
492
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
499
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
493
500
|
if (layer?.optimistic) {
|
|
494
501
|
action = () => {
|
|
495
502
|
for (const id of newIDs) {
|
|
@@ -196,6 +196,13 @@ export type WatchSchemaConfig = {
|
|
|
196
196
|
* logic you need
|
|
197
197
|
*/
|
|
198
198
|
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
199
|
+
/**
|
|
200
|
+
* Write the schema to disk on pull.
|
|
201
|
+
* Useful for IDE integration.
|
|
202
|
+
* Set to false when you have read only access to the schema or directory it's in.
|
|
203
|
+
* Defaults to true
|
|
204
|
+
*/
|
|
205
|
+
writePolledSchema?: boolean;
|
|
199
206
|
};
|
|
200
207
|
export type ScalarSpec = {
|
|
201
208
|
type: string;
|
|
@@ -387,20 +387,21 @@ class CacheInternal {
|
|
|
387
387
|
} else if (Array.isArray(value) && // make typescript happy
|
|
388
388
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
389
389
|
let oldIDs = [...previousValue || []];
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
390
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
391
|
+
oldIDs = oldIDs.filter((id) => {
|
|
392
|
+
for (const layer2 of this.storage.data) {
|
|
393
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
394
|
+
if (operation.fields?.[key])
|
|
395
|
+
for (const listOperation of operation.fields[key]) {
|
|
396
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return true;
|
|
403
|
+
});
|
|
404
|
+
}
|
|
404
405
|
let linkedIDs = [];
|
|
405
406
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
406
407
|
value,
|
|
@@ -419,39 +420,45 @@ class CacheInternal {
|
|
|
419
420
|
layer.writeLink(parent, key, linkedIDs);
|
|
420
421
|
};
|
|
421
422
|
if (applyUpdates && updates) {
|
|
422
|
-
|
|
423
|
-
const
|
|
424
|
-
for (const id of
|
|
423
|
+
const filterIDs = (keep, insert) => {
|
|
424
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
425
|
+
for (const id of keep) {
|
|
425
426
|
if (!id) {
|
|
426
427
|
continue;
|
|
427
428
|
}
|
|
428
429
|
const { value: node } = this.storage.get(id, "node");
|
|
429
|
-
if (
|
|
430
|
+
if (!node) {
|
|
430
431
|
continue;
|
|
431
432
|
}
|
|
432
|
-
|
|
433
|
+
const nodeID = this.storage.get(node, "id");
|
|
434
|
+
if (!nodeID) {
|
|
433
435
|
continue;
|
|
434
436
|
}
|
|
435
|
-
|
|
437
|
+
existingIDs.add(nodeID.value);
|
|
436
438
|
}
|
|
437
|
-
|
|
439
|
+
return insert.filter((id) => {
|
|
438
440
|
if (!id) {
|
|
439
441
|
return true;
|
|
440
442
|
}
|
|
441
|
-
const { value:
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
443
|
+
const { value: node } = this.storage.get(id, "node");
|
|
444
|
+
if (!node) {
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
const nodeID = this.storage.get(node, "id");
|
|
448
|
+
if (!nodeID) {
|
|
449
|
+
return true;
|
|
445
450
|
}
|
|
446
|
-
return
|
|
451
|
+
return !existingIDs.has(nodeID.value);
|
|
447
452
|
});
|
|
448
|
-
}
|
|
453
|
+
};
|
|
449
454
|
for (const update of applyUpdates) {
|
|
450
455
|
if (update !== "replace" && !updates.includes(update)) {
|
|
451
456
|
continue;
|
|
452
457
|
}
|
|
453
458
|
if (update === "prepend") {
|
|
454
|
-
linkedIDs = newIDs.concat(
|
|
459
|
+
linkedIDs = newIDs.concat(
|
|
460
|
+
filterIDs(newIDs, oldIDs)
|
|
461
|
+
);
|
|
455
462
|
if (layer?.optimistic) {
|
|
456
463
|
action = () => {
|
|
457
464
|
for (const id of newIDs) {
|
|
@@ -462,7 +469,7 @@ class CacheInternal {
|
|
|
462
469
|
};
|
|
463
470
|
}
|
|
464
471
|
} else if (update === "append") {
|
|
465
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
472
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
466
473
|
if (layer?.optimistic) {
|
|
467
474
|
action = () => {
|
|
468
475
|
for (const id of newIDs) {
|
|
@@ -196,6 +196,13 @@ export type WatchSchemaConfig = {
|
|
|
196
196
|
* logic you need
|
|
197
197
|
*/
|
|
198
198
|
headers?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
199
|
+
/**
|
|
200
|
+
* Write the schema to disk on pull.
|
|
201
|
+
* Useful for IDE integration.
|
|
202
|
+
* Set to false when you have read only access to the schema or directory it's in.
|
|
203
|
+
* Defaults to true
|
|
204
|
+
*/
|
|
205
|
+
writePolledSchema?: boolean;
|
|
199
206
|
};
|
|
200
207
|
export type ScalarSpec = {
|
|
201
208
|
type: string;
|
package/build/test-cjs/index.js
CHANGED
|
@@ -64950,20 +64950,21 @@ var CacheInternal = class {
|
|
|
64950
64950
|
} else if (Array.isArray(value) && // make typescript happy
|
|
64951
64951
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
64952
64952
|
let oldIDs = [...previousValue || []];
|
|
64953
|
-
|
|
64954
|
-
|
|
64955
|
-
|
|
64956
|
-
|
|
64957
|
-
|
|
64958
|
-
|
|
64959
|
-
|
|
64960
|
-
|
|
64961
|
-
|
|
64962
|
-
|
|
64963
|
-
|
|
64964
|
-
|
|
64965
|
-
|
|
64966
|
-
|
|
64953
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
64954
|
+
oldIDs = oldIDs.filter((id) => {
|
|
64955
|
+
for (const layer2 of this.storage.data) {
|
|
64956
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
64957
|
+
if (operation.fields?.[key])
|
|
64958
|
+
for (const listOperation of operation.fields[key]) {
|
|
64959
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
64960
|
+
return false;
|
|
64961
|
+
}
|
|
64962
|
+
}
|
|
64963
|
+
}
|
|
64964
|
+
}
|
|
64965
|
+
return true;
|
|
64966
|
+
});
|
|
64967
|
+
}
|
|
64967
64968
|
let linkedIDs = [];
|
|
64968
64969
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
64969
64970
|
value,
|
|
@@ -64982,39 +64983,45 @@ var CacheInternal = class {
|
|
|
64982
64983
|
layer.writeLink(parent2, key, linkedIDs);
|
|
64983
64984
|
};
|
|
64984
64985
|
if (applyUpdates && updates) {
|
|
64985
|
-
|
|
64986
|
-
const
|
|
64987
|
-
for (const id of
|
|
64986
|
+
const filterIDs = (keep, insert) => {
|
|
64987
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
64988
|
+
for (const id of keep) {
|
|
64988
64989
|
if (!id) {
|
|
64989
64990
|
continue;
|
|
64990
64991
|
}
|
|
64991
64992
|
const { value: node } = this.storage.get(id, "node");
|
|
64992
|
-
if (
|
|
64993
|
+
if (!node) {
|
|
64993
64994
|
continue;
|
|
64994
64995
|
}
|
|
64995
|
-
|
|
64996
|
+
const nodeID = this.storage.get(node, "id");
|
|
64997
|
+
if (!nodeID) {
|
|
64996
64998
|
continue;
|
|
64997
64999
|
}
|
|
64998
|
-
|
|
65000
|
+
existingIDs.add(nodeID.value);
|
|
64999
65001
|
}
|
|
65000
|
-
|
|
65002
|
+
return insert.filter((id) => {
|
|
65001
65003
|
if (!id) {
|
|
65002
65004
|
return true;
|
|
65003
65005
|
}
|
|
65004
|
-
const { value:
|
|
65005
|
-
|
|
65006
|
-
|
|
65007
|
-
return false;
|
|
65006
|
+
const { value: node } = this.storage.get(id, "node");
|
|
65007
|
+
if (!node) {
|
|
65008
|
+
return true;
|
|
65008
65009
|
}
|
|
65009
|
-
|
|
65010
|
+
const nodeID = this.storage.get(node, "id");
|
|
65011
|
+
if (!nodeID) {
|
|
65012
|
+
return true;
|
|
65013
|
+
}
|
|
65014
|
+
return !existingIDs.has(nodeID.value);
|
|
65010
65015
|
});
|
|
65011
|
-
}
|
|
65016
|
+
};
|
|
65012
65017
|
for (const update of applyUpdates) {
|
|
65013
65018
|
if (update !== "replace" && !updates.includes(update)) {
|
|
65014
65019
|
continue;
|
|
65015
65020
|
}
|
|
65016
65021
|
if (update === "prepend") {
|
|
65017
|
-
linkedIDs = newIDs.concat(
|
|
65022
|
+
linkedIDs = newIDs.concat(
|
|
65023
|
+
filterIDs(newIDs, oldIDs)
|
|
65024
|
+
);
|
|
65018
65025
|
if (layer?.optimistic) {
|
|
65019
65026
|
action = () => {
|
|
65020
65027
|
for (const id of newIDs) {
|
|
@@ -65025,7 +65032,7 @@ var CacheInternal = class {
|
|
|
65025
65032
|
};
|
|
65026
65033
|
}
|
|
65027
65034
|
} else if (update === "append") {
|
|
65028
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
65035
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
65029
65036
|
if (layer?.optimistic) {
|
|
65030
65037
|
action = () => {
|
|
65031
65038
|
for (const id of newIDs) {
|
|
@@ -65637,6 +65644,7 @@ var Config = class {
|
|
|
65637
65644
|
routesDir;
|
|
65638
65645
|
schemaPollInterval;
|
|
65639
65646
|
schemaPollTimeout;
|
|
65647
|
+
schemaPollWriteToDisk = false;
|
|
65640
65648
|
schemaPollHeaders;
|
|
65641
65649
|
pluginMode = false;
|
|
65642
65650
|
plugins = [];
|
|
@@ -65713,6 +65721,7 @@ var Config = class {
|
|
|
65713
65721
|
this.routesDir = join(this.projectRoot, "src", "routes");
|
|
65714
65722
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
65715
65723
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
65724
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
65716
65725
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
65717
65726
|
this.rootDir = join(this.projectRoot, this.runtimeDir);
|
|
65718
65727
|
this.persistedQueriesPath = persistedQueriesPath ?? join(this.rootDir, "persisted_queries.json");
|
|
@@ -65745,11 +65754,17 @@ var Config = class {
|
|
|
65745
65754
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
65746
65755
|
for (const plugin2 of this.plugins) {
|
|
65747
65756
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
65748
|
-
|
|
65757
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
65758
|
+
if (!runtimeDir && !staticDir) {
|
|
65749
65759
|
continue;
|
|
65750
65760
|
}
|
|
65751
|
-
const
|
|
65752
|
-
|
|
65761
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
65762
|
+
if (!dir) {
|
|
65763
|
+
continue;
|
|
65764
|
+
}
|
|
65765
|
+
const includePath = relative(this.projectRoot, dir);
|
|
65766
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
65767
|
+
}
|
|
65753
65768
|
}
|
|
65754
65769
|
return include;
|
|
65755
65770
|
}
|
|
@@ -65803,6 +65818,15 @@ var Config = class {
|
|
|
65803
65818
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
65804
65819
|
);
|
|
65805
65820
|
}
|
|
65821
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
65822
|
+
if (!plugin2.staticRuntime) {
|
|
65823
|
+
return null;
|
|
65824
|
+
}
|
|
65825
|
+
return join(
|
|
65826
|
+
dirname(plugin2.filepath),
|
|
65827
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
65828
|
+
);
|
|
65829
|
+
}
|
|
65806
65830
|
async sourceFiles() {
|
|
65807
65831
|
return [
|
|
65808
65832
|
...new Set(
|
|
@@ -65999,6 +66023,9 @@ var Config = class {
|
|
|
65999
66023
|
pluginRuntimeDirectory(name) {
|
|
66000
66024
|
return join(this.pluginDirectory(name), "runtime");
|
|
66001
66025
|
}
|
|
66026
|
+
pluginStaticRuntimeDirectory(name) {
|
|
66027
|
+
return join(this.pluginDirectory(name), "static");
|
|
66028
|
+
}
|
|
66002
66029
|
get pluginRootDirectory() {
|
|
66003
66030
|
return houdini_mode.is_testing ? "../../../" : join(this.rootDir, "plugins");
|
|
66004
66031
|
}
|
|
@@ -70703,6 +70730,11 @@ async function writeIndexFile2(config, docs) {
|
|
|
70703
70730
|
module: relative2(config.pluginRuntimeDirectory(plugin2.name))
|
|
70704
70731
|
});
|
|
70705
70732
|
}
|
|
70733
|
+
if (plugin2.staticRuntime) {
|
|
70734
|
+
body += exportStar({
|
|
70735
|
+
module: relative2(config.pluginStaticRuntimeDirectory(plugin2.name))
|
|
70736
|
+
});
|
|
70737
|
+
}
|
|
70706
70738
|
}
|
|
70707
70739
|
await fs_exports.writeFile(path_exports.join(config.rootDir, "index.js"), body);
|
|
70708
70740
|
}
|