houdini 1.0.11 → 1.1.1-next.0
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 +659 -330
- package/build/cmd-esm/index.js +659 -330
- package/build/codegen/generators/artifacts/selection.d.ts +5 -2
- package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
- package/build/codegen/transforms/{composeQueries.d.ts → collectDefinitions.d.ts} +1 -1
- package/build/codegen/transforms/fragmentVariables.d.ts +2 -4
- package/build/codegen/transforms/index.d.ts +1 -1
- package/build/codegen/utils/flattenSelections.d.ts +2 -2
- package/build/codegen-cjs/index.js +604 -326
- package/build/codegen-esm/index.js +604 -326
- package/build/lib/config.d.ts +10 -1
- package/build/lib/deepMerge.d.ts +1 -1
- package/build/lib/types.d.ts +1 -0
- package/build/lib-cjs/index.js +261 -115
- package/build/lib-esm/index.js +260 -115
- package/build/runtime/cache/cache.d.ts +17 -6
- package/build/runtime/client/documentStore.d.ts +1 -0
- package/build/runtime/client/plugins/cache.d.ts +3 -2
- package/build/runtime/client/plugins/fragment.d.ts +2 -0
- package/build/runtime/client/plugins/index.d.ts +1 -0
- package/build/runtime/lib/scalars.d.ts +0 -1
- package/build/runtime/lib/types.d.ts +55 -7
- package/build/runtime-cjs/cache/cache.d.ts +17 -6
- package/build/runtime-cjs/cache/cache.js +89 -21
- package/build/runtime-cjs/cache/lists.js +2 -1
- package/build/runtime-cjs/cache/subscription.js +11 -2
- package/build/runtime-cjs/client/documentStore.d.ts +1 -0
- package/build/runtime-cjs/client/documentStore.js +5 -14
- package/build/runtime-cjs/client/index.js +2 -1
- package/build/runtime-cjs/client/plugins/cache.d.ts +3 -2
- package/build/runtime-cjs/client/plugins/cache.js +19 -3
- package/build/runtime-cjs/client/plugins/fetch.js +4 -1
- package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -0
- package/build/runtime-cjs/client/plugins/fragment.js +76 -0
- package/build/runtime-cjs/client/plugins/index.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/index.js +1 -0
- package/build/runtime-cjs/client/plugins/query.js +3 -5
- package/build/runtime-cjs/lib/scalars.d.ts +0 -1
- package/build/runtime-cjs/lib/scalars.js +2 -43
- package/build/runtime-cjs/lib/types.d.ts +55 -7
- package/build/runtime-cjs/lib/types.js +5 -2
- package/build/runtime-cjs/public/tests/test.js +4 -2
- package/build/runtime-esm/cache/cache.d.ts +17 -6
- package/build/runtime-esm/cache/cache.js +89 -22
- package/build/runtime-esm/cache/lists.js +2 -1
- package/build/runtime-esm/cache/subscription.js +11 -2
- package/build/runtime-esm/client/documentStore.d.ts +1 -0
- package/build/runtime-esm/client/documentStore.js +6 -15
- package/build/runtime-esm/client/index.js +3 -1
- package/build/runtime-esm/client/plugins/cache.d.ts +3 -2
- package/build/runtime-esm/client/plugins/cache.js +19 -3
- package/build/runtime-esm/client/plugins/fetch.js +5 -2
- package/build/runtime-esm/client/plugins/fragment.d.ts +2 -0
- package/build/runtime-esm/client/plugins/fragment.js +46 -0
- package/build/runtime-esm/client/plugins/index.d.ts +1 -0
- package/build/runtime-esm/client/plugins/index.js +1 -0
- package/build/runtime-esm/client/plugins/query.js +3 -5
- package/build/runtime-esm/lib/scalars.d.ts +0 -1
- package/build/runtime-esm/lib/scalars.js +1 -41
- package/build/runtime-esm/lib/types.d.ts +55 -7
- package/build/runtime-esm/lib/types.js +3 -1
- package/build/runtime-esm/public/tests/test.js +4 -2
- package/build/test-cjs/index.js +658 -329
- package/build/test-esm/index.js +658 -329
- package/build/vite-cjs/index.js +657 -328
- package/build/vite-esm/index.js +657 -328
- package/package.json +2 -2
|
@@ -28,11 +28,14 @@ __export(cache_exports, {
|
|
|
28
28
|
});
|
|
29
29
|
module.exports = __toCommonJS(cache_exports);
|
|
30
30
|
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
|
+
var import_cache2 = require("../../cache/cache");
|
|
31
32
|
var import_types = require("../../lib/types");
|
|
33
|
+
const serverSide = typeof globalThis.window === "undefined";
|
|
32
34
|
const cachePolicy = ({
|
|
33
35
|
enabled,
|
|
34
36
|
setFetching,
|
|
35
|
-
cache: localCache = import_cache.default
|
|
37
|
+
cache: localCache = import_cache.default,
|
|
38
|
+
serverSideFallback = true
|
|
36
39
|
}) => () => {
|
|
37
40
|
return {
|
|
38
41
|
network(ctx, { initialValue, next, resolve, marshalVariables }) {
|
|
@@ -83,13 +86,26 @@ const cachePolicy = ({
|
|
|
83
86
|
},
|
|
84
87
|
afterNetwork(ctx, { resolve, value, marshalVariables }) {
|
|
85
88
|
if (value.source !== import_types.DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
86
|
-
|
|
89
|
+
const targetCache = serverSide && serverSideFallback ? new import_cache2.Cache({ disabled: false }) : localCache;
|
|
90
|
+
let layer;
|
|
91
|
+
if (!serverSide && ctx.cacheParams?.layer) {
|
|
92
|
+
layer = ctx.cacheParams.layer.id;
|
|
93
|
+
}
|
|
94
|
+
targetCache.write({
|
|
87
95
|
...ctx.cacheParams,
|
|
88
|
-
layer
|
|
96
|
+
layer,
|
|
89
97
|
selection: ctx.artifact.selection,
|
|
90
98
|
data: value.data,
|
|
91
99
|
variables: marshalVariables(ctx)
|
|
92
100
|
});
|
|
101
|
+
value = {
|
|
102
|
+
...value,
|
|
103
|
+
data: targetCache.read({
|
|
104
|
+
selection: ctx.artifact.selection,
|
|
105
|
+
variables: marshalVariables(ctx),
|
|
106
|
+
ignoreMasking: serverSide
|
|
107
|
+
}).data
|
|
108
|
+
};
|
|
93
109
|
}
|
|
94
110
|
resolve(ctx, value);
|
|
95
111
|
}
|
|
@@ -27,7 +27,10 @@ var import_types = require("../../lib/types");
|
|
|
27
27
|
const fetch = (target) => {
|
|
28
28
|
return () => {
|
|
29
29
|
return {
|
|
30
|
-
async network(ctx, { client, resolve, marshalVariables }) {
|
|
30
|
+
async network(ctx, { client, initialValue, resolve, marshalVariables }) {
|
|
31
|
+
if (ctx.artifact.kind === import_types.ArtifactKind.Fragment) {
|
|
32
|
+
return resolve(ctx, initialValue);
|
|
33
|
+
}
|
|
31
34
|
const fetch2 = ctx.fetch ?? globalThis.fetch;
|
|
32
35
|
const fetchParams = {
|
|
33
36
|
text: ctx.text,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var fragment_exports = {};
|
|
26
|
+
__export(fragment_exports, {
|
|
27
|
+
fragment: () => fragment
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(fragment_exports);
|
|
30
|
+
var import_cache = __toESM(require("../../cache"), 1);
|
|
31
|
+
var import_types = require("../../lib/types");
|
|
32
|
+
var import_utils = require("../utils");
|
|
33
|
+
const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
|
|
34
|
+
let subscriptionSpec = null;
|
|
35
|
+
return {
|
|
36
|
+
start(ctx, { next, resolve, variablesChanged, marshalVariables }) {
|
|
37
|
+
if (!ctx.stuff.parentID) {
|
|
38
|
+
return next(ctx);
|
|
39
|
+
}
|
|
40
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
41
|
+
if (subscriptionSpec) {
|
|
42
|
+
import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
43
|
+
}
|
|
44
|
+
const variables = marshalVariables(ctx);
|
|
45
|
+
subscriptionSpec = {
|
|
46
|
+
rootType: ctx.artifact.rootType,
|
|
47
|
+
selection: ctx.artifact.selection,
|
|
48
|
+
variables: () => variables,
|
|
49
|
+
parentID: ctx.stuff.parentID,
|
|
50
|
+
set: (newValue) => {
|
|
51
|
+
resolve(ctx, {
|
|
52
|
+
data: newValue,
|
|
53
|
+
errors: null,
|
|
54
|
+
fetching: false,
|
|
55
|
+
partial: false,
|
|
56
|
+
stale: false,
|
|
57
|
+
source: import_types.DataSource.Cache,
|
|
58
|
+
variables
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
import_cache.default.subscribe(subscriptionSpec, variables);
|
|
63
|
+
}
|
|
64
|
+
next(ctx);
|
|
65
|
+
},
|
|
66
|
+
cleanup() {
|
|
67
|
+
if (subscriptionSpec) {
|
|
68
|
+
import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
fragment
|
|
76
|
+
});
|
|
@@ -18,6 +18,7 @@ module.exports = __toCommonJS(plugins_exports);
|
|
|
18
18
|
__reExport(plugins_exports, require("./fetch"), module.exports);
|
|
19
19
|
__reExport(plugins_exports, require("./cache"), module.exports);
|
|
20
20
|
__reExport(plugins_exports, require("./query"), module.exports);
|
|
21
|
+
__reExport(plugins_exports, require("./fragment"), module.exports);
|
|
21
22
|
__reExport(plugins_exports, require("./mutation"), module.exports);
|
|
22
23
|
__reExport(plugins_exports, require("./subscription"), module.exports);
|
|
23
24
|
__reExport(plugins_exports, require("./throwOnError"), module.exports);
|
|
@@ -33,7 +33,6 @@ var import_utils = require("../utils");
|
|
|
33
33
|
const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
|
|
34
34
|
let subscriptionSpec = null;
|
|
35
35
|
let lastVariables = null;
|
|
36
|
-
let artifactName = "";
|
|
37
36
|
return {
|
|
38
37
|
start(ctx, { next }) {
|
|
39
38
|
ctx.variables = {
|
|
@@ -43,8 +42,7 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
|
|
|
43
42
|
next(ctx);
|
|
44
43
|
},
|
|
45
44
|
end(ctx, { resolve, marshalVariables, variablesChanged }) {
|
|
46
|
-
if (variablesChanged(ctx)) {
|
|
47
|
-
artifactName = ctx.artifact.name;
|
|
45
|
+
if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
|
|
48
46
|
if (subscriptionSpec) {
|
|
49
47
|
import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
50
48
|
}
|
|
@@ -65,13 +63,13 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
|
|
|
65
63
|
});
|
|
66
64
|
}
|
|
67
65
|
};
|
|
68
|
-
import_cache.default.subscribe(subscriptionSpec, lastVariables
|
|
66
|
+
import_cache.default.subscribe(subscriptionSpec, lastVariables);
|
|
69
67
|
}
|
|
70
68
|
resolve(ctx);
|
|
71
69
|
},
|
|
72
70
|
cleanup() {
|
|
73
71
|
if (subscriptionSpec) {
|
|
74
|
-
import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.()
|
|
72
|
+
import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
|
|
75
73
|
lastVariables = null;
|
|
76
74
|
}
|
|
77
75
|
}
|
|
@@ -10,6 +10,5 @@ export declare function marshalInputs<T>({ artifact, input, config, rootType, }:
|
|
|
10
10
|
rootType?: string;
|
|
11
11
|
config: ConfigFile;
|
|
12
12
|
}): {} | null | undefined;
|
|
13
|
-
export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
|
|
14
13
|
export declare function isScalar(config: ConfigFile, type: string): boolean;
|
|
15
14
|
export declare function parseScalar(config: ConfigFile, type: string, value?: string): string | number | boolean | undefined;
|
|
@@ -21,8 +21,7 @@ __export(scalars_exports, {
|
|
|
21
21
|
isScalar: () => isScalar,
|
|
22
22
|
marshalInputs: () => marshalInputs,
|
|
23
23
|
marshalSelection: () => marshalSelection,
|
|
24
|
-
parseScalar: () => parseScalar
|
|
25
|
-
unmarshalSelection: () => unmarshalSelection
|
|
24
|
+
parseScalar: () => parseScalar
|
|
26
25
|
});
|
|
27
26
|
module.exports = __toCommonJS(scalars_exports);
|
|
28
27
|
var import_config = require("./config");
|
|
@@ -102,45 +101,6 @@ function marshalInputs({
|
|
|
102
101
|
})
|
|
103
102
|
);
|
|
104
103
|
}
|
|
105
|
-
function unmarshalSelection(config, selection, data) {
|
|
106
|
-
if (data === null || typeof data === "undefined") {
|
|
107
|
-
return data;
|
|
108
|
-
}
|
|
109
|
-
if (Array.isArray(data)) {
|
|
110
|
-
return data.map((val) => unmarshalSelection(config, selection, val));
|
|
111
|
-
}
|
|
112
|
-
const targetSelection = (0, import_selection.getFieldsForType)(selection, data["__typename"]);
|
|
113
|
-
return Object.fromEntries(
|
|
114
|
-
Object.entries(data).map(([fieldName, value]) => {
|
|
115
|
-
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
116
|
-
if (!type) {
|
|
117
|
-
return [fieldName, value];
|
|
118
|
-
}
|
|
119
|
-
if (selection2) {
|
|
120
|
-
return [
|
|
121
|
-
fieldName,
|
|
122
|
-
unmarshalSelection(config, selection2, value)
|
|
123
|
-
];
|
|
124
|
-
}
|
|
125
|
-
if (value === null) {
|
|
126
|
-
return [fieldName, value];
|
|
127
|
-
}
|
|
128
|
-
if (config.scalars?.[type]?.marshal) {
|
|
129
|
-
const unmarshalFn = config.scalars[type]?.unmarshal;
|
|
130
|
-
if (!unmarshalFn) {
|
|
131
|
-
throw new Error(
|
|
132
|
-
`scalar type ${type} is missing an \`unmarshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
if (Array.isArray(value)) {
|
|
136
|
-
return [fieldName, value.map(unmarshalFn)];
|
|
137
|
-
}
|
|
138
|
-
return [fieldName, unmarshalFn(value)];
|
|
139
|
-
}
|
|
140
|
-
return [fieldName, value];
|
|
141
|
-
})
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
104
|
function isScalar(config, type) {
|
|
145
105
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
146
106
|
}
|
|
@@ -181,6 +141,5 @@ function parseScalar(config, type, value) {
|
|
|
181
141
|
isScalar,
|
|
182
142
|
marshalInputs,
|
|
183
143
|
marshalSelection,
|
|
184
|
-
parseScalar
|
|
185
|
-
unmarshalSelection
|
|
144
|
+
parseScalar
|
|
186
145
|
});
|
|
@@ -24,6 +24,7 @@ declare global {
|
|
|
24
24
|
changed: boolean;
|
|
25
25
|
};
|
|
26
26
|
optimisticResponse?: GraphQLObject;
|
|
27
|
+
parentID?: string;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
30
|
}
|
|
@@ -84,7 +85,7 @@ export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
|
|
|
84
85
|
direction: 'forward' | 'backward' | 'both';
|
|
85
86
|
mode: PaginateModes;
|
|
86
87
|
};
|
|
87
|
-
pluginData
|
|
88
|
+
pluginData: Record<string, any>;
|
|
88
89
|
};
|
|
89
90
|
export type HoudiniFetchContext = {
|
|
90
91
|
variables: () => {};
|
|
@@ -128,6 +129,7 @@ export type GraphQLObject = {
|
|
|
128
129
|
};
|
|
129
130
|
export type GraphQLValue = number | string | boolean | null | GraphQLObject | GraphQLValue[] | undefined;
|
|
130
131
|
export type SubscriptionSelection = {
|
|
132
|
+
fragments?: Record<string, ValueMap>;
|
|
131
133
|
fields?: {
|
|
132
134
|
[fieldName: string]: {
|
|
133
135
|
type: string;
|
|
@@ -140,12 +142,11 @@ export type SubscriptionSelection = {
|
|
|
140
142
|
type: string;
|
|
141
143
|
};
|
|
142
144
|
updates?: string[];
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
145
|
+
visible?: boolean;
|
|
146
|
+
filters?: Record<string, {
|
|
147
|
+
kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
|
|
148
|
+
value: string | number | boolean;
|
|
149
|
+
}>;
|
|
149
150
|
selection?: SubscriptionSelection;
|
|
150
151
|
abstract?: boolean;
|
|
151
152
|
};
|
|
@@ -189,4 +190,51 @@ export type RequestPayload<GraphQLObject = any> = {
|
|
|
189
190
|
};
|
|
190
191
|
export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
|
|
191
192
|
export type ValueOf<Parent> = Parent[keyof Parent];
|
|
193
|
+
export declare const fragmentKey = " $fragments";
|
|
194
|
+
export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
|
|
195
|
+
export type ValueMap = Record<string, ValueNode>;
|
|
196
|
+
interface IntValueNode {
|
|
197
|
+
readonly kind: 'IntValue';
|
|
198
|
+
readonly value: string;
|
|
199
|
+
}
|
|
200
|
+
interface FloatValueNode {
|
|
201
|
+
readonly kind: 'FloatValue';
|
|
202
|
+
readonly value: string;
|
|
203
|
+
}
|
|
204
|
+
interface StringValueNode {
|
|
205
|
+
readonly kind: 'StringValue';
|
|
206
|
+
readonly value: string;
|
|
207
|
+
}
|
|
208
|
+
interface BooleanValueNode {
|
|
209
|
+
readonly kind: 'BooleanValue';
|
|
210
|
+
readonly value: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface NullValueNode {
|
|
213
|
+
readonly kind: 'NullValue';
|
|
214
|
+
}
|
|
215
|
+
interface EnumValueNode {
|
|
216
|
+
readonly kind: 'EnumValue';
|
|
217
|
+
readonly value: string;
|
|
218
|
+
}
|
|
219
|
+
interface ListValueNode {
|
|
220
|
+
readonly kind: 'ListValue';
|
|
221
|
+
readonly values: ReadonlyArray<ValueNode>;
|
|
222
|
+
}
|
|
223
|
+
interface ObjectValueNode {
|
|
224
|
+
readonly kind: 'ObjectValue';
|
|
225
|
+
readonly fields: ReadonlyArray<ObjectFieldNode>;
|
|
226
|
+
}
|
|
227
|
+
interface ObjectFieldNode {
|
|
228
|
+
readonly kind: 'ObjectField';
|
|
229
|
+
readonly name: NameNode;
|
|
230
|
+
readonly value: ValueNode;
|
|
231
|
+
}
|
|
232
|
+
interface NameNode {
|
|
233
|
+
readonly kind: 'Name';
|
|
234
|
+
readonly value: string;
|
|
235
|
+
}
|
|
236
|
+
interface VariableNode {
|
|
237
|
+
readonly kind: 'Variable';
|
|
238
|
+
readonly name: NameNode;
|
|
239
|
+
}
|
|
192
240
|
export {};
|
|
@@ -26,7 +26,8 @@ __export(types_exports, {
|
|
|
26
26
|
CompiledSubscriptionKind: () => CompiledSubscriptionKind,
|
|
27
27
|
DataSource: () => DataSource,
|
|
28
28
|
PaginateMode: () => PaginateMode,
|
|
29
|
-
RefetchUpdateMode: () => RefetchUpdateMode
|
|
29
|
+
RefetchUpdateMode: () => RefetchUpdateMode,
|
|
30
|
+
fragmentKey: () => fragmentKey
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(types_exports);
|
|
32
33
|
const CachePolicy = {
|
|
@@ -59,6 +60,7 @@ const DataSource = {
|
|
|
59
60
|
Network: "network",
|
|
60
61
|
Ssr: "ssr"
|
|
61
62
|
};
|
|
63
|
+
const fragmentKey = " $fragments";
|
|
62
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
65
|
0 && (module.exports = {
|
|
64
66
|
ArtifactKind,
|
|
@@ -69,5 +71,6 @@ const DataSource = {
|
|
|
69
71
|
CompiledSubscriptionKind,
|
|
70
72
|
DataSource,
|
|
71
73
|
PaginateMode,
|
|
72
|
-
RefetchUpdateMode
|
|
74
|
+
RefetchUpdateMode,
|
|
75
|
+
fragmentKey
|
|
73
76
|
});
|
|
@@ -35,7 +35,8 @@ const testFragment = (selection) => ({
|
|
|
35
35
|
raw: "",
|
|
36
36
|
name: "",
|
|
37
37
|
rootType: "User",
|
|
38
|
-
selection
|
|
38
|
+
selection,
|
|
39
|
+
pluginData: {}
|
|
39
40
|
}
|
|
40
41
|
});
|
|
41
42
|
const testQuery = (selection) => ({
|
|
@@ -45,7 +46,8 @@ const testQuery = (selection) => ({
|
|
|
45
46
|
raw: "",
|
|
46
47
|
name: "",
|
|
47
48
|
rootType: "Query",
|
|
48
|
-
selection
|
|
49
|
+
selection,
|
|
50
|
+
pluginData: {}
|
|
49
51
|
}
|
|
50
52
|
});
|
|
51
53
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ConfigFile } from '../lib/config';
|
|
2
|
-
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
|
|
2
|
+
import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, SubscriptionSpec, ValueMap } from '../lib/types';
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
@@ -10,7 +10,9 @@ import { InMemoryStorage } from './storage';
|
|
|
10
10
|
import { InMemorySubscriptions, type FieldSelection } from './subscription';
|
|
11
11
|
export declare class Cache {
|
|
12
12
|
_internal_unstable: CacheInternal;
|
|
13
|
-
constructor(config?: ConfigFile
|
|
13
|
+
constructor({ disabled, ...config }?: ConfigFile & {
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
});
|
|
14
16
|
write({ layer: layerID, notifySubscribers, ...args }: {
|
|
15
17
|
data: {
|
|
16
18
|
[key: string]: GraphQLValue;
|
|
@@ -44,10 +46,11 @@ export declare class Cache {
|
|
|
44
46
|
when?: {};
|
|
45
47
|
}): void;
|
|
46
48
|
getFieldTime(id: string, field: string): number | null | undefined;
|
|
49
|
+
config(): ConfigFile;
|
|
47
50
|
}
|
|
48
51
|
declare class CacheInternal {
|
|
49
52
|
private _disabled;
|
|
50
|
-
|
|
53
|
+
_config?: ConfigFile;
|
|
51
54
|
storage: InMemoryStorage;
|
|
52
55
|
subscriptions: InMemorySubscriptions;
|
|
53
56
|
lists: ListManager;
|
|
@@ -55,7 +58,7 @@ declare class CacheInternal {
|
|
|
55
58
|
lifetimes: GarbageCollector;
|
|
56
59
|
staleManager: StaleManager;
|
|
57
60
|
schema: SchemaManager;
|
|
58
|
-
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, schema, }: {
|
|
61
|
+
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, schema, disabled, config, }: {
|
|
59
62
|
storage: InMemoryStorage;
|
|
60
63
|
subscriptions: InMemorySubscriptions;
|
|
61
64
|
lists: ListManager;
|
|
@@ -63,7 +66,10 @@ declare class CacheInternal {
|
|
|
63
66
|
lifetimes: GarbageCollector;
|
|
64
67
|
staleManager: StaleManager;
|
|
65
68
|
schema: SchemaManager;
|
|
69
|
+
disabled: boolean;
|
|
70
|
+
config?: ConfigFile;
|
|
66
71
|
});
|
|
72
|
+
get config(): ConfigFile;
|
|
67
73
|
setConfig(config: ConfigFile): void;
|
|
68
74
|
writeSelection({ data, selection, variables, parent, applyUpdates, layer, toNotify, forceNotify, forceStale, }: {
|
|
69
75
|
data: {
|
|
@@ -81,11 +87,12 @@ declare class CacheInternal {
|
|
|
81
87
|
forceNotify?: boolean;
|
|
82
88
|
forceStale?: boolean;
|
|
83
89
|
}): FieldSelection[];
|
|
84
|
-
getSelection({ selection, parent, variables, stepsFromConnection, }: {
|
|
90
|
+
getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, }: {
|
|
85
91
|
selection: SubscriptionSelection;
|
|
86
92
|
parent?: string;
|
|
87
93
|
variables?: {};
|
|
88
94
|
stepsFromConnection?: number | null;
|
|
95
|
+
ignoreMasking?: boolean;
|
|
89
96
|
}): {
|
|
90
97
|
data: GraphQLObject | null;
|
|
91
98
|
partial: boolean;
|
|
@@ -96,11 +103,12 @@ declare class CacheInternal {
|
|
|
96
103
|
id(type: string, id: string): string | null;
|
|
97
104
|
idFields(type: string): string[];
|
|
98
105
|
computeID(type: string, data: any): string;
|
|
99
|
-
hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, }: {
|
|
106
|
+
hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, }: {
|
|
100
107
|
fields: SubscriptionSelection;
|
|
101
108
|
variables?: {};
|
|
102
109
|
linkedList: NestedList;
|
|
103
110
|
stepsFromConnection: number | null;
|
|
111
|
+
ignoreMasking: boolean;
|
|
104
112
|
}): {
|
|
105
113
|
data: NestedList<GraphQLValue>;
|
|
106
114
|
partial: boolean;
|
|
@@ -125,5 +133,8 @@ declare class CacheInternal {
|
|
|
125
133
|
};
|
|
126
134
|
collectGarbage(): void;
|
|
127
135
|
}
|
|
136
|
+
export declare function evaluateFragmentVariables(variables: ValueMap, args: GraphQLObject): {
|
|
137
|
+
[k: string]: GraphQLValue;
|
|
138
|
+
};
|
|
128
139
|
export declare const rootID = "_ROOT_";
|
|
129
140
|
export {};
|