houdini 1.3.1 → 1.4.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 +143 -28
- package/build/cmd-esm/index.js +143 -28
- package/build/codegen-cjs/index.js +123 -10
- package/build/codegen-esm/index.js +123 -10
- package/build/lib/config.d.ts +1 -0
- package/build/lib/router/types.d.ts +3 -1
- package/build/lib-cjs/index.js +92 -19
- package/build/lib-esm/index.js +91 -19
- package/build/runtime/cache/cache.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +3 -1
- package/build/runtime/lib/config.d.ts +10 -1
- package/build/runtime/lib/types.d.ts +14 -2
- package/build/runtime-cjs/cache/cache.d.ts +1 -1
- package/build/runtime-cjs/cache/cache.js +31 -5
- package/build/runtime-cjs/cache/lists.d.ts +3 -1
- package/build/runtime-cjs/cache/lists.js +15 -1
- package/build/runtime-cjs/client/documentStore.js +27 -7
- package/build/runtime-cjs/client/plugins/fetch.js +5 -0
- package/build/runtime-cjs/lib/config.d.ts +10 -1
- package/build/runtime-cjs/lib/types.d.ts +14 -2
- package/build/runtime-cjs/lib/types.js +7 -0
- package/build/runtime-cjs/router/match.js +1 -1
- package/build/runtime-esm/cache/cache.d.ts +1 -1
- package/build/runtime-esm/cache/cache.js +31 -5
- package/build/runtime-esm/cache/lists.d.ts +3 -1
- package/build/runtime-esm/cache/lists.js +15 -1
- package/build/runtime-esm/client/documentStore.js +28 -8
- package/build/runtime-esm/client/plugins/fetch.js +5 -0
- package/build/runtime-esm/lib/config.d.ts +10 -1
- package/build/runtime-esm/lib/types.d.ts +14 -2
- package/build/runtime-esm/lib/types.js +6 -0
- package/build/runtime-esm/router/match.js +1 -1
- package/build/test-cjs/index.js +129 -15
- package/build/test-esm/index.js +129 -15
- package/build/vite/ast.d.ts +8 -2
- package/build/vite-cjs/index.js +374 -255
- package/build/vite-esm/index.js +374 -255
- package/package.json +3 -3
package/build/test-esm/index.js
CHANGED
|
@@ -53980,6 +53980,11 @@ var CachePolicy = {
|
|
|
53980
53980
|
CacheAndNetwork: "CacheAndNetwork",
|
|
53981
53981
|
NoCache: "NoCache"
|
|
53982
53982
|
};
|
|
53983
|
+
var DedupeMatchMode = {
|
|
53984
|
+
Variables: "Variables",
|
|
53985
|
+
Operation: "Operation",
|
|
53986
|
+
None: "None"
|
|
53987
|
+
};
|
|
53983
53988
|
var PaginateMode = {
|
|
53984
53989
|
Infinite: "Infinite",
|
|
53985
53990
|
SinglePage: "SinglePage"
|
|
@@ -54559,7 +54564,18 @@ var ListManager = class {
|
|
|
54559
54564
|
}
|
|
54560
54565
|
lists = /* @__PURE__ */ new Map();
|
|
54561
54566
|
listsByField = /* @__PURE__ */ new Map();
|
|
54562
|
-
get(listName, id, allLists) {
|
|
54567
|
+
get(listName, id, allLists, skipMatches) {
|
|
54568
|
+
const lists = this.getLists(listName, id, allLists);
|
|
54569
|
+
if (!lists) {
|
|
54570
|
+
return null;
|
|
54571
|
+
}
|
|
54572
|
+
if (skipMatches) {
|
|
54573
|
+
return new ListCollection(lists.lists.filter((list) => !skipMatches.has(list.fieldRef)));
|
|
54574
|
+
} else {
|
|
54575
|
+
return lists;
|
|
54576
|
+
}
|
|
54577
|
+
}
|
|
54578
|
+
getLists(listName, id, allLists) {
|
|
54563
54579
|
const matches = this.lists.get(listName);
|
|
54564
54580
|
if (!matches || matches.size === 0) {
|
|
54565
54581
|
return null;
|
|
@@ -54681,6 +54697,9 @@ var List = class {
|
|
|
54681
54697
|
this.manager = manager;
|
|
54682
54698
|
this.abstract = abstract;
|
|
54683
54699
|
}
|
|
54700
|
+
get fieldRef() {
|
|
54701
|
+
return `${this.recordID}.${this.key}`;
|
|
54702
|
+
}
|
|
54684
54703
|
when(when) {
|
|
54685
54704
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
54686
54705
|
}
|
|
@@ -55833,8 +55852,8 @@ var Cache = class {
|
|
|
55833
55852
|
variables
|
|
55834
55853
|
);
|
|
55835
55854
|
}
|
|
55836
|
-
list(name, parentID, allLists) {
|
|
55837
|
-
const handler = this._internal_unstable.lists.get(name, parentID, allLists);
|
|
55855
|
+
list(name, parentID, allLists, skipMatches) {
|
|
55856
|
+
const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
|
|
55838
55857
|
if (!handler) {
|
|
55839
55858
|
throw new Error(
|
|
55840
55859
|
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
@@ -56249,6 +56268,7 @@ var CacheInternal = class {
|
|
|
56249
56268
|
});
|
|
56250
56269
|
}
|
|
56251
56270
|
}
|
|
56271
|
+
const processedOperations = /* @__PURE__ */ new Set();
|
|
56252
56272
|
for (const operation of operations || []) {
|
|
56253
56273
|
let parentID;
|
|
56254
56274
|
if (operation.parentID) {
|
|
@@ -56268,7 +56288,12 @@ var CacheInternal = class {
|
|
|
56268
56288
|
const targets = Array.isArray(value) ? value : [value];
|
|
56269
56289
|
for (const target of targets) {
|
|
56270
56290
|
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
56271
|
-
this.cache.list(
|
|
56291
|
+
this.cache.list(
|
|
56292
|
+
operation.list,
|
|
56293
|
+
parentID,
|
|
56294
|
+
operation.target === "all",
|
|
56295
|
+
processedOperations
|
|
56296
|
+
).when(operation.when).addToList(
|
|
56272
56297
|
fieldSelection,
|
|
56273
56298
|
target,
|
|
56274
56299
|
variables,
|
|
@@ -56276,7 +56301,12 @@ var CacheInternal = class {
|
|
|
56276
56301
|
layer
|
|
56277
56302
|
);
|
|
56278
56303
|
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
56279
|
-
this.cache.list(
|
|
56304
|
+
this.cache.list(
|
|
56305
|
+
operation.list,
|
|
56306
|
+
parentID,
|
|
56307
|
+
operation.target === "all",
|
|
56308
|
+
processedOperations
|
|
56309
|
+
).when(operation.when).toggleElement({
|
|
56280
56310
|
selection: fieldSelection,
|
|
56281
56311
|
data: target,
|
|
56282
56312
|
variables,
|
|
@@ -56284,7 +56314,12 @@ var CacheInternal = class {
|
|
|
56284
56314
|
layer
|
|
56285
56315
|
});
|
|
56286
56316
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
56287
|
-
this.cache.list(
|
|
56317
|
+
this.cache.list(
|
|
56318
|
+
operation.list,
|
|
56319
|
+
parentID,
|
|
56320
|
+
operation.target === "all",
|
|
56321
|
+
processedOperations
|
|
56322
|
+
).when(operation.when).remove(target, variables, layer);
|
|
56288
56323
|
} else if (operation.action === "delete" && operation.type && target) {
|
|
56289
56324
|
const targetID = this.id(operation.type, target);
|
|
56290
56325
|
if (!targetID) {
|
|
@@ -56296,6 +56331,16 @@ var CacheInternal = class {
|
|
|
56296
56331
|
this.cache.delete(targetID, layer);
|
|
56297
56332
|
}
|
|
56298
56333
|
}
|
|
56334
|
+
if (operation.list) {
|
|
56335
|
+
const matchingLists = this.cache.list(
|
|
56336
|
+
operation.list,
|
|
56337
|
+
parentID,
|
|
56338
|
+
operation.target === "all"
|
|
56339
|
+
);
|
|
56340
|
+
for (const list of matchingLists.lists) {
|
|
56341
|
+
processedOperations.add(list.fieldRef);
|
|
56342
|
+
}
|
|
56343
|
+
}
|
|
56299
56344
|
}
|
|
56300
56345
|
}
|
|
56301
56346
|
return toNotify;
|
|
@@ -56763,8 +56808,9 @@ var Config = class {
|
|
|
56763
56808
|
localSchema;
|
|
56764
56809
|
projectRoot;
|
|
56765
56810
|
schema;
|
|
56811
|
+
runtimeDir;
|
|
56766
56812
|
schemaPath;
|
|
56767
|
-
persistedQueriesPath
|
|
56813
|
+
persistedQueriesPath;
|
|
56768
56814
|
exclude;
|
|
56769
56815
|
scalars;
|
|
56770
56816
|
module = "esm";
|
|
@@ -56805,6 +56851,7 @@ var Config = class {
|
|
|
56805
56851
|
let {
|
|
56806
56852
|
schema,
|
|
56807
56853
|
schemaPath = "./schema.graphql",
|
|
56854
|
+
runtimeDir = "$houdini",
|
|
56808
56855
|
exclude = [],
|
|
56809
56856
|
module = "esm",
|
|
56810
56857
|
scalars,
|
|
@@ -56843,6 +56890,7 @@ var Config = class {
|
|
|
56843
56890
|
this.projectRoot = dirname(
|
|
56844
56891
|
projectDir ? join(process.cwd(), projectDir) : filepath
|
|
56845
56892
|
);
|
|
56893
|
+
this.runtimeDir = runtimeDir;
|
|
56846
56894
|
this.scalars = scalars;
|
|
56847
56895
|
this.cacheBufferSize = cacheBufferSize;
|
|
56848
56896
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
@@ -56857,11 +56905,9 @@ var Config = class {
|
|
|
56857
56905
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
56858
56906
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
56859
56907
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
56860
|
-
this.rootDir = join(this.projectRoot,
|
|
56908
|
+
this.rootDir = join(this.projectRoot, this.runtimeDir);
|
|
56909
|
+
this.persistedQueriesPath = persistedQueriesPath ?? join(this.rootDir, "persisted_queries.json");
|
|
56861
56910
|
this.#fragmentVariableMaps = {};
|
|
56862
|
-
if (persistedQueriesPath) {
|
|
56863
|
-
this.persistedQueriesPath = persistedQueriesPath;
|
|
56864
|
-
}
|
|
56865
56911
|
if (defaultKeys) {
|
|
56866
56912
|
this.defaultKeys = defaultKeys;
|
|
56867
56913
|
}
|
|
@@ -59221,14 +59267,27 @@ async function paginate(config, documents) {
|
|
|
59221
59267
|
return {
|
|
59222
59268
|
...node,
|
|
59223
59269
|
variableDefinitions: finalVariables,
|
|
59224
|
-
directives: [
|
|
59270
|
+
directives: config.configFile.supressPaginationDeduplication ? node.directives : [
|
|
59225
59271
|
...node.directives || [],
|
|
59226
59272
|
{
|
|
59227
59273
|
kind: graphql13.Kind.DIRECTIVE,
|
|
59228
59274
|
name: {
|
|
59229
59275
|
kind: graphql13.Kind.NAME,
|
|
59230
59276
|
value: config.dedupeDirective
|
|
59231
|
-
}
|
|
59277
|
+
},
|
|
59278
|
+
arguments: [
|
|
59279
|
+
{
|
|
59280
|
+
kind: "Argument",
|
|
59281
|
+
name: {
|
|
59282
|
+
kind: "Name",
|
|
59283
|
+
value: "match"
|
|
59284
|
+
},
|
|
59285
|
+
value: {
|
|
59286
|
+
kind: "EnumValue",
|
|
59287
|
+
value: DedupeMatchMode.Variables
|
|
59288
|
+
}
|
|
59289
|
+
}
|
|
59290
|
+
]
|
|
59232
59291
|
}
|
|
59233
59292
|
]
|
|
59234
59293
|
};
|
|
@@ -59596,6 +59655,46 @@ function objectNode([type, defaultValue]) {
|
|
|
59596
59655
|
return node;
|
|
59597
59656
|
}
|
|
59598
59657
|
var pageInfoSelection = [
|
|
59658
|
+
{
|
|
59659
|
+
kind: graphql13.Kind.FIELD,
|
|
59660
|
+
name: {
|
|
59661
|
+
kind: graphql13.Kind.NAME,
|
|
59662
|
+
value: "pageInfo"
|
|
59663
|
+
},
|
|
59664
|
+
selectionSet: {
|
|
59665
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
59666
|
+
selections: [
|
|
59667
|
+
{
|
|
59668
|
+
kind: graphql13.Kind.FIELD,
|
|
59669
|
+
name: {
|
|
59670
|
+
kind: graphql13.Kind.NAME,
|
|
59671
|
+
value: "hasPreviousPage"
|
|
59672
|
+
}
|
|
59673
|
+
},
|
|
59674
|
+
{
|
|
59675
|
+
kind: graphql13.Kind.FIELD,
|
|
59676
|
+
name: {
|
|
59677
|
+
kind: graphql13.Kind.NAME,
|
|
59678
|
+
value: "hasNextPage"
|
|
59679
|
+
}
|
|
59680
|
+
},
|
|
59681
|
+
{
|
|
59682
|
+
kind: graphql13.Kind.FIELD,
|
|
59683
|
+
name: {
|
|
59684
|
+
kind: graphql13.Kind.NAME,
|
|
59685
|
+
value: "startCursor"
|
|
59686
|
+
}
|
|
59687
|
+
},
|
|
59688
|
+
{
|
|
59689
|
+
kind: graphql13.Kind.FIELD,
|
|
59690
|
+
name: {
|
|
59691
|
+
kind: graphql13.Kind.NAME,
|
|
59692
|
+
value: "endCursor"
|
|
59693
|
+
}
|
|
59694
|
+
}
|
|
59695
|
+
]
|
|
59696
|
+
}
|
|
59697
|
+
},
|
|
59599
59698
|
{
|
|
59600
59699
|
kind: graphql13.Kind.FIELD,
|
|
59601
59700
|
name: {
|
|
@@ -60585,7 +60684,13 @@ function artifactGenerator(stats) {
|
|
|
60585
60684
|
const cancelFirstArg = dedupeDirective.arguments?.find(
|
|
60586
60685
|
(arg) => arg.name.value === "cancelFirst"
|
|
60587
60686
|
);
|
|
60588
|
-
|
|
60687
|
+
const matchArg = dedupeDirective.arguments?.find(
|
|
60688
|
+
(arg) => arg.name.value === "match"
|
|
60689
|
+
);
|
|
60690
|
+
dedupe = {
|
|
60691
|
+
cancel: cancelFirstArg && cancelFirstArg.value.kind === "BooleanValue" && cancelFirstArg.value ? "first" : "last",
|
|
60692
|
+
match: matchArg && matchArg.value.kind === "EnumValue" ? matchArg.value.value : DedupeMatchMode.Operation
|
|
60693
|
+
};
|
|
60589
60694
|
}
|
|
60590
60695
|
selectionSet = operation.selectionSet;
|
|
60591
60696
|
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
@@ -64252,11 +64357,20 @@ directive @${config.paginateDirective}(${config.listOrPaginateNameArg}: String,
|
|
|
64252
64357
|
"""
|
|
64253
64358
|
directive @${config.listPrependDirective} on FRAGMENT_SPREAD
|
|
64254
64359
|
|
|
64360
|
+
enum DedupeMatchMode {
|
|
64361
|
+
${DedupeMatchMode.Variables}
|
|
64362
|
+
${DedupeMatchMode.Operation}
|
|
64363
|
+
${DedupeMatchMode.None}
|
|
64364
|
+
}
|
|
64365
|
+
|
|
64255
64366
|
"""
|
|
64256
64367
|
@${config.dedupeDirective} is used to prevent an operation from running more than once at the same time.
|
|
64257
64368
|
If the cancelFirst arg is set to true, the response already in flight will be canceled instead of the second one.
|
|
64369
|
+
If match is set to Operation, then a request will be deduplicated any time there is a request with the same operation.
|
|
64370
|
+
If it's set to Variables then the request will only be deduplicated if the variables match. If match is set to None,
|
|
64371
|
+
then the request will never be deduplicated.
|
|
64258
64372
|
"""
|
|
64259
|
-
directive @${config.dedupeDirective}(cancelFirst: Boolean) on QUERY | MUTATION
|
|
64373
|
+
directive @${config.dedupeDirective}(cancelFirst: Boolean, match: DedupeMatchMode) on QUERY | MUTATION
|
|
64260
64374
|
|
|
64261
64375
|
"""
|
|
64262
64376
|
@${config.optimisticKeyDirective} is used to identify a field as an optimistic key
|
package/build/vite/ast.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as recast from 'recast';
|
|
2
2
|
type Statement = recast.types.namedTypes.Statement;
|
|
3
3
|
type Program = recast.types.namedTypes.Program;
|
|
4
|
+
type ExportNamedDeclaration = recast.types.namedTypes.ExportNamedDeclaration;
|
|
4
5
|
type FunctionDeclaration = recast.types.namedTypes.FunctionDeclaration;
|
|
6
|
+
type Identifier = recast.types.namedTypes.Identifier;
|
|
5
7
|
type ArrowFunctionExpression = recast.types.namedTypes.ArrowFunctionExpression;
|
|
6
8
|
type FunctionExpression = recast.types.namedTypes.FunctionExpression;
|
|
9
|
+
type CallExpression = recast.types.namedTypes.CallExpression;
|
|
7
10
|
export declare function find_insert_index(script: Program): number;
|
|
8
|
-
export declare function find_exported_fn(body: Statement[], name: string):
|
|
11
|
+
export declare function find_exported_fn(body: Statement[], name: string): {
|
|
12
|
+
declaration: FunctionDeclaration | FunctionExpression | ArrowFunctionExpression | null | Identifier | CallExpression;
|
|
13
|
+
export: ExportNamedDeclaration;
|
|
14
|
+
} | null;
|
|
9
15
|
export declare function find_exported_id(program: Program, name: string): recast.types.namedTypes.ExportNamedDeclaration | undefined;
|
|
10
16
|
export {};
|