houdini 0.18.3 → 0.19.1
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 +961 -534
- package/build/cmd-esm/index.js +961 -534
- package/build/codegen/generators/artifacts/utils.d.ts +2 -1
- package/build/codegen/generators/runtime/index.d.ts +2 -2
- package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +1 -1
- package/build/codegen/generators/typescript/imperativeCache.d.ts +2 -0
- package/build/codegen/generators/typescript/typeReference.d.ts +1 -1
- package/build/codegen-cjs/index.js +861 -483
- package/build/codegen-esm/index.js +861 -483
- package/build/lib/config.d.ts +27 -10
- package/build/lib-cjs/index.js +172 -64
- package/build/lib-esm/index.js +171 -64
- package/build/runtime/cache/cache.d.ts +5 -2
- package/build/runtime/cache/schema.d.ts +21 -0
- package/build/runtime/generated.d.ts +4 -0
- package/build/runtime/index.d.ts +6 -3
- package/build/runtime/lib/config.d.ts +7 -3
- package/build/runtime/lib/network.d.ts +2 -2
- package/build/runtime/lib/types.d.ts +2 -2
- package/build/runtime/public/cache.d.ts +19 -0
- package/build/runtime/public/index.d.ts +1 -0
- package/build/runtime/public/list.d.ts +18 -0
- package/build/runtime/public/record.d.ts +31 -0
- package/build/runtime/public/tests/test.d.ts +114 -0
- package/build/runtime/public/types.d.ts +36 -0
- package/build/runtime-cjs/cache/cache.d.ts +5 -2
- package/build/runtime-cjs/cache/cache.js +16 -5
- package/build/runtime-cjs/cache/schema.d.ts +21 -0
- package/build/runtime-cjs/cache/schema.js +66 -0
- package/build/runtime-cjs/generated.d.ts +4 -0
- package/build/runtime-cjs/generated.js +16 -0
- package/build/runtime-cjs/index.d.ts +6 -3
- package/build/runtime-cjs/index.js +4 -0
- package/build/runtime-cjs/lib/config.d.ts +7 -3
- package/build/runtime-cjs/lib/network.d.ts +2 -2
- package/build/runtime-cjs/lib/network.js +2 -2
- package/build/runtime-cjs/lib/types.d.ts +2 -2
- package/build/runtime-cjs/public/cache.d.ts +19 -0
- package/build/runtime-cjs/public/cache.js +97 -0
- package/build/runtime-cjs/public/index.d.ts +1 -0
- package/build/runtime-cjs/public/index.js +28 -0
- package/build/runtime-cjs/public/list.d.ts +18 -0
- package/build/runtime-cjs/public/list.js +163 -0
- package/build/runtime-cjs/public/record.d.ts +31 -0
- package/build/runtime-cjs/public/record.js +249 -0
- package/build/runtime-cjs/public/tests/test.d.ts +114 -0
- package/build/runtime-cjs/public/tests/test.js +31 -0
- package/build/runtime-cjs/public/types.d.ts +36 -0
- package/build/runtime-cjs/public/types.js +16 -0
- package/build/runtime-esm/cache/cache.d.ts +5 -2
- package/build/runtime-esm/cache/cache.js +16 -5
- package/build/runtime-esm/cache/schema.d.ts +21 -0
- package/build/runtime-esm/cache/schema.js +42 -0
- package/build/runtime-esm/generated.d.ts +4 -0
- package/build/runtime-esm/generated.js +0 -0
- package/build/runtime-esm/index.d.ts +6 -3
- package/build/runtime-esm/index.js +5 -2
- package/build/runtime-esm/lib/config.d.ts +7 -3
- package/build/runtime-esm/lib/network.d.ts +2 -2
- package/build/runtime-esm/lib/network.js +2 -2
- package/build/runtime-esm/lib/types.d.ts +2 -2
- package/build/runtime-esm/public/cache.d.ts +19 -0
- package/build/runtime-esm/public/cache.js +72 -0
- package/build/runtime-esm/public/index.d.ts +1 -0
- package/build/runtime-esm/public/index.js +4 -0
- package/build/runtime-esm/public/list.d.ts +18 -0
- package/build/runtime-esm/public/list.js +139 -0
- package/build/runtime-esm/public/record.d.ts +31 -0
- package/build/runtime-esm/public/record.js +222 -0
- package/build/runtime-esm/public/tests/test.d.ts +114 -0
- package/build/runtime-esm/public/tests/test.js +7 -0
- package/build/runtime-esm/public/types.d.ts +36 -0
- package/build/runtime-esm/public/types.js +0 -0
- package/build/test-cjs/index.js +857 -466
- package/build/test-esm/index.js +857 -466
- package/build/vite-cjs/index.js +939 -527
- package/build/vite-esm/index.js +939 -527
- package/package.json +2 -2
package/build/lib-esm/index.js
CHANGED
|
@@ -61932,6 +61932,46 @@ var ListCollection = class {
|
|
|
61932
61932
|
}
|
|
61933
61933
|
};
|
|
61934
61934
|
|
|
61935
|
+
// src/runtime/cache/schema.ts
|
|
61936
|
+
var SchemaManager = class {
|
|
61937
|
+
cache;
|
|
61938
|
+
fieldTypes = {};
|
|
61939
|
+
constructor(cache) {
|
|
61940
|
+
this.cache = cache;
|
|
61941
|
+
}
|
|
61942
|
+
setFieldType({
|
|
61943
|
+
parent,
|
|
61944
|
+
key,
|
|
61945
|
+
type,
|
|
61946
|
+
nullable = false,
|
|
61947
|
+
link
|
|
61948
|
+
}) {
|
|
61949
|
+
let parensIndex = key.indexOf("(");
|
|
61950
|
+
if (parensIndex !== -1) {
|
|
61951
|
+
key = key.substring(0, parensIndex);
|
|
61952
|
+
}
|
|
61953
|
+
if (parent === rootID) {
|
|
61954
|
+
parent = "Query";
|
|
61955
|
+
} else if (parent.includes(":")) {
|
|
61956
|
+
parent = parent.substring(0, parent.indexOf(":"));
|
|
61957
|
+
}
|
|
61958
|
+
if (!this.fieldTypes[parent]) {
|
|
61959
|
+
this.fieldTypes[parent] = {};
|
|
61960
|
+
}
|
|
61961
|
+
this.fieldTypes[parent][key] = {
|
|
61962
|
+
type,
|
|
61963
|
+
nullable,
|
|
61964
|
+
link: !!link
|
|
61965
|
+
};
|
|
61966
|
+
}
|
|
61967
|
+
fieldType(type, field) {
|
|
61968
|
+
return this.fieldTypes[type]?.[field] || null;
|
|
61969
|
+
}
|
|
61970
|
+
get config() {
|
|
61971
|
+
return this.cache._internal_unstable.config;
|
|
61972
|
+
}
|
|
61973
|
+
};
|
|
61974
|
+
|
|
61935
61975
|
// src/runtime/cache/storage.ts
|
|
61936
61976
|
var InMemoryStorage = class {
|
|
61937
61977
|
data;
|
|
@@ -62499,7 +62539,7 @@ var InMemorySubscriptions = class {
|
|
|
62499
62539
|
};
|
|
62500
62540
|
|
|
62501
62541
|
// src/runtime/cache/cache.ts
|
|
62502
|
-
var
|
|
62542
|
+
var Cache3 = class {
|
|
62503
62543
|
_internal_unstable;
|
|
62504
62544
|
constructor(config) {
|
|
62505
62545
|
this._internal_unstable = new CacheInternal({
|
|
@@ -62507,7 +62547,8 @@ var Cache2 = class {
|
|
|
62507
62547
|
storage: new InMemoryStorage(),
|
|
62508
62548
|
subscriptions: new InMemorySubscriptions(this),
|
|
62509
62549
|
lists: new ListManager(this, rootID),
|
|
62510
|
-
lifetimes: new GarbageCollector(this)
|
|
62550
|
+
lifetimes: new GarbageCollector(this),
|
|
62551
|
+
schema: new SchemaManager(this)
|
|
62511
62552
|
});
|
|
62512
62553
|
if (config) {
|
|
62513
62554
|
this.setConfig(defaultConfigValues(config));
|
|
@@ -62593,18 +62634,21 @@ var CacheInternal = class {
|
|
|
62593
62634
|
lists;
|
|
62594
62635
|
cache;
|
|
62595
62636
|
lifetimes;
|
|
62637
|
+
schema;
|
|
62596
62638
|
constructor({
|
|
62597
62639
|
storage,
|
|
62598
62640
|
subscriptions,
|
|
62599
62641
|
lists,
|
|
62600
62642
|
cache,
|
|
62601
|
-
lifetimes
|
|
62643
|
+
lifetimes,
|
|
62644
|
+
schema
|
|
62602
62645
|
}) {
|
|
62603
62646
|
this.storage = storage;
|
|
62604
62647
|
this.subscriptions = subscriptions;
|
|
62605
62648
|
this.lists = lists;
|
|
62606
62649
|
this.cache = cache;
|
|
62607
62650
|
this.lifetimes = lifetimes;
|
|
62651
|
+
this.schema = schema;
|
|
62608
62652
|
this._disabled = typeof globalThis.window === "undefined";
|
|
62609
62653
|
try {
|
|
62610
62654
|
if (process.env.HOUDINI_TEST === "true") {
|
|
@@ -62620,7 +62664,6 @@ var CacheInternal = class {
|
|
|
62620
62664
|
data,
|
|
62621
62665
|
selection,
|
|
62622
62666
|
variables = {},
|
|
62623
|
-
root = rootID,
|
|
62624
62667
|
parent = rootID,
|
|
62625
62668
|
applyUpdates = false,
|
|
62626
62669
|
layer,
|
|
@@ -62643,9 +62686,17 @@ var CacheInternal = class {
|
|
|
62643
62686
|
selection: fieldSelection,
|
|
62644
62687
|
operations,
|
|
62645
62688
|
abstract: isAbstract,
|
|
62646
|
-
update
|
|
62689
|
+
update,
|
|
62690
|
+
nullable
|
|
62647
62691
|
} = targetSelection[field];
|
|
62648
62692
|
const key = evaluateKey(keyRaw, variables);
|
|
62693
|
+
this.schema.setFieldType({
|
|
62694
|
+
parent,
|
|
62695
|
+
key: keyRaw,
|
|
62696
|
+
type: linkedType,
|
|
62697
|
+
nullable,
|
|
62698
|
+
link: !!fieldSelection
|
|
62699
|
+
});
|
|
62649
62700
|
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
62650
62701
|
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
62651
62702
|
const displayLayer = layer.isDisplayLayer(displayLayers);
|
|
@@ -62714,7 +62765,6 @@ var CacheInternal = class {
|
|
|
62714
62765
|
}
|
|
62715
62766
|
if (linkedID) {
|
|
62716
62767
|
this.writeSelection({
|
|
62717
|
-
root,
|
|
62718
62768
|
selection: fieldSelection,
|
|
62719
62769
|
parent: linkedID,
|
|
62720
62770
|
data: value,
|
|
@@ -63105,7 +63155,7 @@ var CacheInternal = class {
|
|
|
63105
63155
|
var rootID = "_ROOT_";
|
|
63106
63156
|
|
|
63107
63157
|
// src/runtime/cache/index.ts
|
|
63108
|
-
var cache_default = new
|
|
63158
|
+
var cache_default = new Cache3();
|
|
63109
63159
|
|
|
63110
63160
|
// src/runtime/lib/types.ts
|
|
63111
63161
|
var CachePolicy = /* @__PURE__ */ ((CachePolicy2) => {
|
|
@@ -63323,6 +63373,7 @@ async function writeFile(filepath, data) {
|
|
|
63323
63373
|
return;
|
|
63324
63374
|
}
|
|
63325
63375
|
if (houdini_mode.is_testing) {
|
|
63376
|
+
import_memfs.fs.mkdirpSync(dirname(filepath));
|
|
63326
63377
|
return import_memfs.fs.writeFileSync(filepath, data);
|
|
63327
63378
|
}
|
|
63328
63379
|
return await fs.writeFile(filepath, data, "utf8");
|
|
@@ -64689,7 +64740,6 @@ var Config = class {
|
|
|
64689
64740
|
rootDir;
|
|
64690
64741
|
projectRoot;
|
|
64691
64742
|
schema;
|
|
64692
|
-
apiUrl;
|
|
64693
64743
|
schemaPath;
|
|
64694
64744
|
persistedQueryPath;
|
|
64695
64745
|
exclude;
|
|
@@ -64729,7 +64779,6 @@ var Config = class {
|
|
|
64729
64779
|
schema,
|
|
64730
64780
|
schemaPath = "./schema.graphql",
|
|
64731
64781
|
exclude = [],
|
|
64732
|
-
apiUrl,
|
|
64733
64782
|
module = "esm",
|
|
64734
64783
|
scalars,
|
|
64735
64784
|
cacheBufferSize,
|
|
@@ -64760,11 +64809,6 @@ var Config = class {
|
|
|
64760
64809
|
logLevel = LogLevel.Summary;
|
|
64761
64810
|
}
|
|
64762
64811
|
this.schemaPath = schemaPath;
|
|
64763
|
-
if (apiUrl && apiUrl.startsWith("env:")) {
|
|
64764
|
-
this.apiUrl = process.env[apiUrl.slice("env:".length)];
|
|
64765
|
-
} else {
|
|
64766
|
-
this.apiUrl = apiUrl;
|
|
64767
|
-
}
|
|
64768
64812
|
this.filepath = filepath;
|
|
64769
64813
|
this.exclude = Array.isArray(exclude) ? exclude : [exclude];
|
|
64770
64814
|
this.module = module;
|
|
@@ -64794,6 +64838,13 @@ var Config = class {
|
|
|
64794
64838
|
};
|
|
64795
64839
|
}
|
|
64796
64840
|
}
|
|
64841
|
+
async apiURL() {
|
|
64842
|
+
if (!this.configFile.apiUrl) {
|
|
64843
|
+
return "";
|
|
64844
|
+
}
|
|
64845
|
+
const env = await this.getEnv();
|
|
64846
|
+
return this.processEnvValues(env, this.configFile.apiUrl);
|
|
64847
|
+
}
|
|
64797
64848
|
get include() {
|
|
64798
64849
|
if (this.configFile.include) {
|
|
64799
64850
|
return Array.isArray(this.configFile.include) ? this.configFile.include : [this.configFile.include];
|
|
@@ -64806,23 +64857,43 @@ var Config = class {
|
|
|
64806
64857
|
pluginConfig(name) {
|
|
64807
64858
|
return this.configFile.plugins?.[name] ?? {};
|
|
64808
64859
|
}
|
|
64809
|
-
|
|
64810
|
-
|
|
64860
|
+
async getEnv() {
|
|
64861
|
+
let env = process.env;
|
|
64862
|
+
for (const plugin of this.plugins) {
|
|
64863
|
+
if (plugin.env) {
|
|
64864
|
+
env = {
|
|
64865
|
+
...await plugin.env({ config: this, env })
|
|
64866
|
+
};
|
|
64867
|
+
}
|
|
64868
|
+
}
|
|
64869
|
+
return env;
|
|
64870
|
+
}
|
|
64871
|
+
processEnvValues(env, value) {
|
|
64872
|
+
let headerValue;
|
|
64873
|
+
if (typeof value === "function") {
|
|
64874
|
+
headerValue = value(env);
|
|
64875
|
+
} else if (value.startsWith("env:")) {
|
|
64876
|
+
headerValue = env[value.slice("env:".length)];
|
|
64877
|
+
} else {
|
|
64878
|
+
headerValue = value;
|
|
64879
|
+
}
|
|
64880
|
+
return headerValue;
|
|
64881
|
+
}
|
|
64882
|
+
async pullHeaders() {
|
|
64883
|
+
const env = await this.getEnv();
|
|
64884
|
+
if (typeof this.schemaPollHeaders === "function") {
|
|
64885
|
+
return this.schemaPollHeaders(env);
|
|
64886
|
+
}
|
|
64887
|
+
const headers = Object.fromEntries(
|
|
64811
64888
|
Object.entries(this.schemaPollHeaders || {}).map(([key, value]) => {
|
|
64812
|
-
|
|
64813
|
-
if (typeof value === "function") {
|
|
64814
|
-
headerValue = value(process.env);
|
|
64815
|
-
} else if (value.startsWith("env:")) {
|
|
64816
|
-
headerValue = process.env[value.slice("env:".length)];
|
|
64817
|
-
} else {
|
|
64818
|
-
headerValue = value;
|
|
64819
|
-
}
|
|
64889
|
+
const headerValue = this.processEnvValues(env, value);
|
|
64820
64890
|
if (!headerValue) {
|
|
64821
64891
|
return [];
|
|
64822
64892
|
}
|
|
64823
64893
|
return [key, headerValue];
|
|
64824
|
-
})
|
|
64894
|
+
}).filter(([key]) => key)
|
|
64825
64895
|
);
|
|
64896
|
+
return headers;
|
|
64826
64897
|
}
|
|
64827
64898
|
async sourceFiles() {
|
|
64828
64899
|
return [
|
|
@@ -65228,9 +65299,10 @@ async function getConfig({
|
|
|
65228
65299
|
...extraConfig,
|
|
65229
65300
|
filepath: configPath
|
|
65230
65301
|
});
|
|
65302
|
+
const apiURL = await _config.apiURL();
|
|
65231
65303
|
if (_config.schemaPath && !_config.schema) {
|
|
65232
65304
|
let schemaOk = true;
|
|
65233
|
-
if (
|
|
65305
|
+
if (apiURL) {
|
|
65234
65306
|
if (glob.hasMagic(_config.schemaPath)) {
|
|
65235
65307
|
console.log(
|
|
65236
65308
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
@@ -65238,7 +65310,7 @@ This will prevent your schema from being pulled.`
|
|
|
65238
65310
|
);
|
|
65239
65311
|
} else if (!await readFile(_config.schemaPath)) {
|
|
65240
65312
|
console.log("\u231B Pulling schema from api");
|
|
65241
|
-
schemaOk = await pullSchema(
|
|
65313
|
+
schemaOk = await pullSchema(apiURL, _config.schemaPath);
|
|
65242
65314
|
}
|
|
65243
65315
|
}
|
|
65244
65316
|
if (schemaOk && !noSchema) {
|
|
@@ -65249,10 +65321,11 @@ This will prevent your schema from being pulled.`
|
|
|
65249
65321
|
reject(e2);
|
|
65250
65322
|
throw e2;
|
|
65251
65323
|
}
|
|
65324
|
+
const plugins = [];
|
|
65252
65325
|
for (const [pluginName, plugin_config] of Object.entries(_config.configFile.plugins ?? {})) {
|
|
65253
65326
|
try {
|
|
65254
65327
|
const pluginDirectory = _config.findModule(pluginName);
|
|
65255
|
-
const { default:
|
|
65328
|
+
const { default: pluginFactory } = await import(pathToFileURL(pluginDirectory).toString() + "/build/plugin-esm/index.js");
|
|
65256
65329
|
let include_runtime = false;
|
|
65257
65330
|
try {
|
|
65258
65331
|
await stat(join2(pluginDirectory, "build", "runtime-esm"));
|
|
@@ -65269,8 +65342,8 @@ This will prevent your schema from being pulled.`
|
|
|
65269
65342
|
version = packageJSON.version;
|
|
65270
65343
|
} catch {
|
|
65271
65344
|
}
|
|
65272
|
-
|
|
65273
|
-
...await
|
|
65345
|
+
plugins.push({
|
|
65346
|
+
...await pluginFactory(plugin_config),
|
|
65274
65347
|
name: pluginName,
|
|
65275
65348
|
include_runtime,
|
|
65276
65349
|
version,
|
|
@@ -65282,6 +65355,7 @@ This will prevent your schema from being pulled.`
|
|
|
65282
65355
|
);
|
|
65283
65356
|
}
|
|
65284
65357
|
}
|
|
65358
|
+
_config.plugins = orderedPlugins(plugins);
|
|
65285
65359
|
await Promise.all(_config.plugins.map((plugin) => plugin.after_load?.(_config)));
|
|
65286
65360
|
resolve2(_config);
|
|
65287
65361
|
return _config;
|
|
@@ -65293,6 +65367,16 @@ var LogLevel = /* @__PURE__ */ ((LogLevel2) => {
|
|
|
65293
65367
|
LogLevel2["Quiet"] = "quiet";
|
|
65294
65368
|
return LogLevel2;
|
|
65295
65369
|
})(LogLevel || {});
|
|
65370
|
+
var orderedPlugins = (plugins) => {
|
|
65371
|
+
const ordered = plugins.filter(
|
|
65372
|
+
(plugin) => plugin.order === "before" || plugin.order === void 0
|
|
65373
|
+
);
|
|
65374
|
+
ordered.push(
|
|
65375
|
+
...plugins.filter((plugin) => plugin.order === "core"),
|
|
65376
|
+
...plugins.filter((plugin) => plugin.order === "after")
|
|
65377
|
+
);
|
|
65378
|
+
return ordered;
|
|
65379
|
+
};
|
|
65296
65380
|
|
|
65297
65381
|
// src/lib/graphql.ts
|
|
65298
65382
|
var graphql3 = __toESM(require_graphql2(), 1);
|
|
@@ -65601,47 +65685,69 @@ var graphql4 = __toESM(require_graphql2(), 1);
|
|
|
65601
65685
|
async function find_graphql(config, parsedScript, walker) {
|
|
65602
65686
|
await asyncWalk(parsedScript, {
|
|
65603
65687
|
async enter(node, parent) {
|
|
65604
|
-
if (node.type
|
|
65688
|
+
if (node.type !== "TaggedTemplateExpression" && node.type !== "CallExpression") {
|
|
65689
|
+
return;
|
|
65690
|
+
}
|
|
65691
|
+
let documentString;
|
|
65692
|
+
if (node.type === "TaggedTemplateExpression") {
|
|
65605
65693
|
const expr = node;
|
|
65606
|
-
|
|
65607
|
-
const parsedTag = graphql4.parse(tagContent);
|
|
65608
|
-
if (walker.where && !walker.where(parsedTag)) {
|
|
65694
|
+
if (expr.tag.type !== "Identifier" || expr.tag.name !== "graphql") {
|
|
65609
65695
|
return;
|
|
65610
65696
|
}
|
|
65611
|
-
|
|
65612
|
-
|
|
65613
|
-
|
|
65614
|
-
|
|
65697
|
+
documentString = expr.quasi.quasis[0].value.raw;
|
|
65698
|
+
} else if (node.type === "CallExpression") {
|
|
65699
|
+
const expr = node;
|
|
65700
|
+
if (expr.callee.type !== "Identifier" || expr.callee.name !== "graphql" || expr.arguments.length !== 1) {
|
|
65701
|
+
return;
|
|
65615
65702
|
}
|
|
65616
|
-
|
|
65617
|
-
if (
|
|
65618
|
-
|
|
65703
|
+
const argument = expr.arguments[0];
|
|
65704
|
+
if (argument.type === "TemplateLiteral") {
|
|
65705
|
+
documentString = argument.quasis[0].value.raw;
|
|
65706
|
+
} else if (argument.type === "StringLiteral") {
|
|
65707
|
+
documentString = argument.value;
|
|
65619
65708
|
} else {
|
|
65620
|
-
|
|
65621
|
-
kind = CompiledQueryKind;
|
|
65622
|
-
} else if (definition.operation === "mutation") {
|
|
65623
|
-
kind = CompiledMutationKind;
|
|
65624
|
-
} else {
|
|
65625
|
-
kind = CompiledSubscriptionKind;
|
|
65626
|
-
}
|
|
65709
|
+
return;
|
|
65627
65710
|
}
|
|
65628
|
-
|
|
65629
|
-
|
|
65630
|
-
parsedDocument: parsedTag,
|
|
65631
|
-
node: {
|
|
65632
|
-
...node,
|
|
65633
|
-
...this,
|
|
65634
|
-
remove: this.remove,
|
|
65635
|
-
replaceWith: this.replace
|
|
65636
|
-
},
|
|
65637
|
-
artifact: {
|
|
65638
|
-
name,
|
|
65639
|
-
kind
|
|
65640
|
-
},
|
|
65641
|
-
parent,
|
|
65642
|
-
tagContent
|
|
65643
|
-
});
|
|
65711
|
+
} else {
|
|
65712
|
+
return;
|
|
65644
65713
|
}
|
|
65714
|
+
const parsedTag = graphql4.parse(documentString);
|
|
65715
|
+
if (walker.where && !walker.where(parsedTag)) {
|
|
65716
|
+
return;
|
|
65717
|
+
}
|
|
65718
|
+
const definition = config.extractDefinition(parsedTag);
|
|
65719
|
+
const name = definition.name?.value;
|
|
65720
|
+
if (!name) {
|
|
65721
|
+
throw new Error("Could not find definition name");
|
|
65722
|
+
}
|
|
65723
|
+
let kind;
|
|
65724
|
+
if (definition.kind === "FragmentDefinition") {
|
|
65725
|
+
kind = CompiledFragmentKind;
|
|
65726
|
+
} else {
|
|
65727
|
+
if (definition.operation === "query") {
|
|
65728
|
+
kind = CompiledQueryKind;
|
|
65729
|
+
} else if (definition.operation === "mutation") {
|
|
65730
|
+
kind = CompiledMutationKind;
|
|
65731
|
+
} else {
|
|
65732
|
+
kind = CompiledSubscriptionKind;
|
|
65733
|
+
}
|
|
65734
|
+
}
|
|
65735
|
+
walker.dependency?.(config.artifactPath(parsedTag));
|
|
65736
|
+
await walker.tag({
|
|
65737
|
+
parsedDocument: parsedTag,
|
|
65738
|
+
node: {
|
|
65739
|
+
...node,
|
|
65740
|
+
...this,
|
|
65741
|
+
remove: this.remove,
|
|
65742
|
+
replaceWith: this.replace
|
|
65743
|
+
},
|
|
65744
|
+
artifact: {
|
|
65745
|
+
name,
|
|
65746
|
+
kind
|
|
65747
|
+
},
|
|
65748
|
+
parent,
|
|
65749
|
+
tagContent: documentString
|
|
65750
|
+
});
|
|
65645
65751
|
}
|
|
65646
65752
|
});
|
|
65647
65753
|
}
|
|
@@ -65674,6 +65780,7 @@ export {
|
|
|
65674
65780
|
houdini_mode,
|
|
65675
65781
|
keyFieldsForType,
|
|
65676
65782
|
operation_requires_variables,
|
|
65783
|
+
orderedPlugins,
|
|
65677
65784
|
parentTypeFromAncestors,
|
|
65678
65785
|
parseJS,
|
|
65679
65786
|
parseJSON,
|
|
@@ -2,6 +2,7 @@ import { ConfigFile } from '../lib/config';
|
|
|
2
2
|
import { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import { ListCollection, ListManager } from './lists';
|
|
5
|
+
import { SchemaManager } from './schema';
|
|
5
6
|
import { InMemoryStorage, Layer, LayerID } from './storage';
|
|
6
7
|
import { InMemorySubscriptions } from './subscription';
|
|
7
8
|
export declare class Cache {
|
|
@@ -37,15 +38,17 @@ declare class CacheInternal {
|
|
|
37
38
|
lists: ListManager;
|
|
38
39
|
cache: Cache;
|
|
39
40
|
lifetimes: GarbageCollector;
|
|
40
|
-
|
|
41
|
+
schema: SchemaManager;
|
|
42
|
+
constructor({ storage, subscriptions, lists, cache, lifetimes, schema, }: {
|
|
41
43
|
storage: InMemoryStorage;
|
|
42
44
|
subscriptions: InMemorySubscriptions;
|
|
43
45
|
lists: ListManager;
|
|
44
46
|
cache: Cache;
|
|
45
47
|
lifetimes: GarbageCollector;
|
|
48
|
+
schema: SchemaManager;
|
|
46
49
|
});
|
|
47
50
|
setConfig(config: ConfigFile): void;
|
|
48
|
-
writeSelection({ data, selection, variables,
|
|
51
|
+
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, }: {
|
|
49
52
|
data: {
|
|
50
53
|
[key: string]: GraphQLValue;
|
|
51
54
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ConfigFile } from '../lib';
|
|
2
|
+
import { Cache } from './cache';
|
|
3
|
+
export type TypeInfo = {
|
|
4
|
+
type: string;
|
|
5
|
+
nullable: boolean;
|
|
6
|
+
link: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class SchemaManager {
|
|
9
|
+
cache: Cache;
|
|
10
|
+
fieldTypes: Record<string, Record<string, TypeInfo>>;
|
|
11
|
+
constructor(cache: Cache);
|
|
12
|
+
setFieldType({ parent, key, type, nullable, link, }: {
|
|
13
|
+
parent: string;
|
|
14
|
+
key: string;
|
|
15
|
+
type: string;
|
|
16
|
+
nullable?: boolean;
|
|
17
|
+
link?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
fieldType(type: string, field: string): TypeInfo;
|
|
20
|
+
get config(): ConfigFile;
|
|
21
|
+
}
|
package/build/runtime/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Cache as InternalCache } from './cache/cache';
|
|
2
|
+
import type { CacheTypeDef } from './generated';
|
|
3
|
+
import { Cache } from './public';
|
|
2
4
|
export * from './lib';
|
|
3
|
-
export declare function graphql(str: TemplateStringsArray): any;
|
|
4
|
-
export declare
|
|
5
|
+
export declare function graphql(str: string | TemplateStringsArray): any;
|
|
6
|
+
export declare const cache: Cache<CacheTypeDef>;
|
|
7
|
+
export declare function getCache(): InternalCache;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { GraphQLSchema } from 'graphql';
|
|
3
2
|
import { CachePolicy } from './types';
|
|
4
3
|
export declare function getMockConfig(): ConfigFile | null;
|
|
@@ -35,7 +34,7 @@ export type ConfigFile = {
|
|
|
35
34
|
/**
|
|
36
35
|
* A url to use to pull the schema. For more information: https://www.houdinigraphql.com/api/cli#generate
|
|
37
36
|
*/
|
|
38
|
-
apiUrl?: string;
|
|
37
|
+
apiUrl?: string | ((env: Record<string, string | undefined>) => string);
|
|
39
38
|
/**
|
|
40
39
|
* An object describing custom scalars for your project. For more information: https://www.houdinigraphql.com/api/config#custom-scalars
|
|
41
40
|
*/
|
|
@@ -104,7 +103,7 @@ export type ConfigFile = {
|
|
|
104
103
|
* directly. If the value is a function, the current environment will be passed to your function so you can perform any
|
|
105
104
|
* logic you need
|
|
106
105
|
*/
|
|
107
|
-
schemaPollHeaders?: Record<string, string | ((env:
|
|
106
|
+
schemaPollHeaders?: Record<string, string | ((env: Record<string, string | undefined>) => string)> | ((env: Record<string, string | undefined>) => Record<string, string>);
|
|
108
107
|
/**
|
|
109
108
|
* An object describing the plugins enabled for the project
|
|
110
109
|
*/
|
|
@@ -114,6 +113,11 @@ export type ConfigFile = {
|
|
|
114
113
|
* @default process.cwd()
|
|
115
114
|
*/
|
|
116
115
|
projectDir?: string;
|
|
116
|
+
/**
|
|
117
|
+
* For now, the cache's imperative API is considered unstable. In order to suppress the warning,
|
|
118
|
+
* you must enable this flag.
|
|
119
|
+
*/
|
|
120
|
+
acceptImperativeInstability?: boolean;
|
|
117
121
|
};
|
|
118
122
|
type ScalarMap = {
|
|
119
123
|
[typeName: string]: ScalarSpec;
|
|
@@ -4,7 +4,7 @@ import { CachePolicy, GraphQLObject, MutationArtifact, QueryArtifact, FetchQuery
|
|
|
4
4
|
export declare class HoudiniClient {
|
|
5
5
|
private fetchFn;
|
|
6
6
|
socket: SubscriptionHandler | null | undefined;
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(requestHandler: RequestHandler<any>, subscriptionHandler?: SubscriptionHandler | null);
|
|
8
8
|
handleMultipart(params: FetchParams, args: Parameters<FetchContext['fetch']>): Parameters<FetchContext['fetch']> | undefined;
|
|
9
9
|
sendRequest<_Data>(ctx: FetchContext, params: FetchParams): Promise<RequestPayloadMagic<_Data>>;
|
|
10
10
|
}
|
|
@@ -53,7 +53,7 @@ export type FetchContext = {
|
|
|
53
53
|
export type RequestHandlerArgs = FetchContext & FetchParams & {
|
|
54
54
|
session?: App.Session;
|
|
55
55
|
};
|
|
56
|
-
export type RequestHandler<_Data> = (args: RequestHandlerArgs) => Promise<RequestPayload<_Data>>;
|
|
56
|
+
export type RequestHandler<_Data = any> = (args: RequestHandlerArgs) => Promise<RequestPayload<_Data>>;
|
|
57
57
|
export declare function executeQuery<_Data extends GraphQLObject, _Input extends {}>({ client, artifact, variables, session, setFetching, cached, fetch, metadata, }: {
|
|
58
58
|
client: HoudiniClient;
|
|
59
59
|
artifact: QueryArtifact | MutationArtifact;
|
|
@@ -161,10 +161,10 @@ export type QueryResult<_Data, _Input, _Extra = {}> = {
|
|
|
161
161
|
variables: _Input;
|
|
162
162
|
} & _Extra;
|
|
163
163
|
export type RequestPayload<_Data = any> = {
|
|
164
|
-
data: _Data;
|
|
164
|
+
data: _Data | null;
|
|
165
165
|
errors: {
|
|
166
166
|
message: string;
|
|
167
|
-
}[];
|
|
167
|
+
}[] | null;
|
|
168
168
|
};
|
|
169
169
|
export type RequestPayloadMagic<_Data = any> = {
|
|
170
170
|
ssr: boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Cache as _Cache } from '../cache/cache';
|
|
2
|
+
import { SchemaManager, TypeInfo } from '../cache/schema';
|
|
3
|
+
import { ListCollection } from './list';
|
|
4
|
+
import { Record } from './record';
|
|
5
|
+
import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
|
|
6
|
+
export declare class Cache<Def extends CacheTypeDef> {
|
|
7
|
+
_internal_unstable: _Cache;
|
|
8
|
+
constructor(cache: _Cache);
|
|
9
|
+
validateInstabilityWarning(): void;
|
|
10
|
+
setFieldType(...args: Parameters<SchemaManager['setFieldType']>): void;
|
|
11
|
+
get root(): Record<Def, '__ROOT__'>;
|
|
12
|
+
get<T extends TypeNames<Def>>(type: T, data: IDFields<Def, T>): Record<Def, T>;
|
|
13
|
+
get config(): import("..").ConfigFile;
|
|
14
|
+
list<Name extends ValidLists<Def>>(name: Name, { parentID, allLists }?: {
|
|
15
|
+
parentID?: string;
|
|
16
|
+
allLists?: boolean;
|
|
17
|
+
}): ListCollection<Def, Name>;
|
|
18
|
+
}
|
|
19
|
+
export declare function _typeInfo<Def extends CacheTypeDef>(cache: Cache<Def>, type: string, field: string): TypeInfo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Cache } from './cache';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Cache } from './cache';
|
|
2
|
+
import { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
|
|
3
|
+
export declare class ListCollection<Def extends CacheTypeDef, ListName extends ValidLists<Def>> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor({ parentID, allLists, when, cache, name, }: {
|
|
6
|
+
name: ValidLists<Def>;
|
|
7
|
+
parentID?: string;
|
|
8
|
+
allLists?: boolean;
|
|
9
|
+
when?: ListFilters<Def, ListName>;
|
|
10
|
+
cache: Cache<Def>;
|
|
11
|
+
});
|
|
12
|
+
append(...records: ListType<Def, ListName>[]): void;
|
|
13
|
+
prepend(...records: ListType<Def, ListName>[]): void;
|
|
14
|
+
toggle(where: 'first' | 'last', ...records: ListType<Def, ListName>[]): void;
|
|
15
|
+
when(filter: ListFilters<Def, ListName>): ListCollection<Def, ListName>;
|
|
16
|
+
remove(...records: ListType<Def, ListName>[]): void;
|
|
17
|
+
[Symbol.iterator](): Generator<string, void, unknown>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Cache } from './cache';
|
|
2
|
+
import type { ArgType, CacheTypeDef, FieldType, TypeFieldNames, ValidTypes } from './types';
|
|
3
|
+
export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<Def>> {
|
|
4
|
+
#private;
|
|
5
|
+
type: string;
|
|
6
|
+
idFields: {};
|
|
7
|
+
constructor({ cache, type, id, idFields, }: {
|
|
8
|
+
cache: Cache<Def>;
|
|
9
|
+
type: string;
|
|
10
|
+
idFields: {};
|
|
11
|
+
id: string;
|
|
12
|
+
});
|
|
13
|
+
set<Field extends TypeFieldNames<Def, Type>>({ field, args, value, }: {
|
|
14
|
+
field: Field;
|
|
15
|
+
args?: ArgType<Def, Type, Field>;
|
|
16
|
+
value: FieldType<Def, Type, Field>;
|
|
17
|
+
}): void;
|
|
18
|
+
get<Field extends TypeFieldNames<Def, Type>>({ field, args, }: {
|
|
19
|
+
field: Field;
|
|
20
|
+
args?: ArgType<Def, Type, Field>;
|
|
21
|
+
}): FieldType<Def, Type, Field>;
|
|
22
|
+
delete(): void;
|
|
23
|
+
}
|
|
24
|
+
export declare function computeKey({ field, args }: {
|
|
25
|
+
field: string;
|
|
26
|
+
args?: {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
}): string;
|
|
30
|
+
export declare const stringifyObjectWithNoQuotesOnKeys: (obj_from_json: {}) => string;
|
|
31
|
+
export declare function marshalNestedList(list: any[]): any[];
|