houdini 1.1.7 → 1.2.0-next.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/README.md +1 -1
- package/build/cmd-cjs/index.js +1739 -1256
- package/build/cmd-esm/index.js +1739 -1256
- package/build/codegen/generators/artifacts/selection.d.ts +2 -1
- package/build/codegen/generators/typescript/inlineType.d.ts +5 -2
- package/build/codegen/generators/typescript/loadingState.d.ts +8 -0
- package/build/codegen-cjs/index.js +1701 -1241
- package/build/codegen-esm/index.js +1701 -1241
- package/build/lib/config.d.ts +5 -0
- package/build/lib/graphql.d.ts +5 -1
- package/build/lib/parse.d.ts +11 -1
- package/build/lib/types.d.ts +4 -1
- package/build/lib-cjs/index.js +611 -493
- package/build/lib-esm/index.js +608 -493
- package/build/runtime/cache/cache.d.ts +7 -8
- package/build/runtime/cache/stuff.d.ts +1 -4
- package/build/runtime/client/documentStore.d.ts +6 -3
- package/build/runtime/client/index.d.ts +9 -8
- package/build/runtime/client/plugins/cache.d.ts +1 -1
- package/build/runtime/client/plugins/fetch.d.ts +1 -0
- package/build/runtime/client/plugins/subscription.d.ts +1 -0
- package/build/runtime/client/plugins/throwOnError.d.ts +2 -1
- package/build/runtime/lib/pageInfo.d.ts +7 -0
- package/build/runtime/lib/pagination.d.ts +27 -0
- package/build/runtime/lib/selection.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +79 -4
- package/build/runtime-cjs/cache/cache.d.ts +7 -8
- package/build/runtime-cjs/cache/cache.js +78 -36
- package/build/runtime-cjs/cache/stuff.d.ts +1 -4
- package/build/runtime-cjs/cache/stuff.js +2 -2
- package/build/runtime-cjs/cache/subscription.js +5 -5
- package/build/runtime-cjs/client/documentStore.d.ts +6 -3
- package/build/runtime-cjs/client/documentStore.js +20 -7
- package/build/runtime-cjs/client/index.d.ts +9 -8
- package/build/runtime-cjs/client/index.js +12 -4
- package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
- package/build/runtime-cjs/client/plugins/cache.js +12 -2
- package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/fetch.js +3 -2
- package/build/runtime-cjs/client/plugins/fragment.js +8 -1
- package/build/runtime-cjs/client/plugins/query.js +2 -1
- package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -0
- package/build/runtime-cjs/client/plugins/subscription.js +1 -0
- package/build/runtime-cjs/client/plugins/throwOnError.d.ts +2 -1
- package/build/runtime-cjs/lib/config.js +2 -1
- package/build/runtime-cjs/lib/pageInfo.d.ts +7 -0
- package/build/runtime-cjs/lib/pageInfo.js +79 -0
- package/build/runtime-cjs/lib/pagination.d.ts +27 -0
- package/build/runtime-cjs/lib/pagination.js +219 -0
- package/build/runtime-cjs/lib/scalars.js +1 -1
- package/build/runtime-cjs/lib/selection.d.ts +1 -1
- package/build/runtime-cjs/lib/selection.js +28 -1
- package/build/runtime-cjs/lib/types.d.ts +79 -4
- package/build/runtime-cjs/lib/types.js +3 -0
- package/build/runtime-esm/cache/cache.d.ts +7 -8
- package/build/runtime-esm/cache/cache.js +79 -37
- package/build/runtime-esm/cache/stuff.d.ts +1 -4
- package/build/runtime-esm/cache/stuff.js +2 -2
- package/build/runtime-esm/cache/subscription.js +5 -5
- package/build/runtime-esm/client/documentStore.d.ts +6 -3
- package/build/runtime-esm/client/documentStore.js +20 -7
- package/build/runtime-esm/client/index.d.ts +9 -8
- package/build/runtime-esm/client/index.js +15 -7
- package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
- package/build/runtime-esm/client/plugins/cache.js +12 -2
- package/build/runtime-esm/client/plugins/fetch.d.ts +1 -0
- package/build/runtime-esm/client/plugins/fetch.js +3 -2
- package/build/runtime-esm/client/plugins/fragment.js +8 -1
- package/build/runtime-esm/client/plugins/query.js +2 -1
- package/build/runtime-esm/client/plugins/subscription.d.ts +1 -0
- package/build/runtime-esm/client/plugins/subscription.js +1 -0
- package/build/runtime-esm/client/plugins/throwOnError.d.ts +2 -1
- package/build/runtime-esm/lib/config.js +2 -1
- package/build/runtime-esm/lib/pageInfo.d.ts +7 -0
- package/build/runtime-esm/lib/pageInfo.js +52 -0
- package/build/runtime-esm/lib/pagination.d.ts +27 -0
- package/build/runtime-esm/lib/pagination.js +194 -0
- package/build/runtime-esm/lib/scalars.js +1 -1
- package/build/runtime-esm/lib/selection.d.ts +1 -1
- package/build/runtime-esm/lib/selection.js +28 -1
- package/build/runtime-esm/lib/types.d.ts +79 -4
- package/build/runtime-esm/lib/types.js +2 -0
- package/build/test/index.d.ts +15 -0
- package/build/test-cjs/index.js +1706 -1223
- package/build/test-esm/index.js +1706 -1223
- package/build/vite-cjs/index.js +1757 -1274
- package/build/vite-esm/index.js +1757 -1274
- package/package.json +5 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pagination_exports = {};
|
|
20
|
+
__export(pagination_exports, {
|
|
21
|
+
cursorHandlers: () => cursorHandlers,
|
|
22
|
+
offsetHandlers: () => offsetHandlers
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(pagination_exports);
|
|
25
|
+
var import_config = require("./config");
|
|
26
|
+
var import_deepEquals = require("./deepEquals");
|
|
27
|
+
var import_pageInfo = require("./pageInfo");
|
|
28
|
+
var import_types = require("./types");
|
|
29
|
+
function cursorHandlers({
|
|
30
|
+
artifact,
|
|
31
|
+
fetchUpdate: parentFetchUpdate,
|
|
32
|
+
fetch: parentFetch,
|
|
33
|
+
getState,
|
|
34
|
+
getVariables,
|
|
35
|
+
getSession
|
|
36
|
+
}) {
|
|
37
|
+
const loadPage = async ({
|
|
38
|
+
pageSizeVar,
|
|
39
|
+
input,
|
|
40
|
+
functionName,
|
|
41
|
+
metadata = {},
|
|
42
|
+
fetch,
|
|
43
|
+
where
|
|
44
|
+
}) => {
|
|
45
|
+
const config = (0, import_config.getCurrentConfig)();
|
|
46
|
+
const loadVariables = {
|
|
47
|
+
...getVariables(),
|
|
48
|
+
...input
|
|
49
|
+
};
|
|
50
|
+
if (!loadVariables[pageSizeVar] && !artifact.refetch.pageSize) {
|
|
51
|
+
throw (0, import_pageInfo.missingPageSizeError)(functionName);
|
|
52
|
+
}
|
|
53
|
+
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
54
|
+
await (isSinglePage ? parentFetch : parentFetchUpdate)(
|
|
55
|
+
{
|
|
56
|
+
variables: loadVariables,
|
|
57
|
+
fetch,
|
|
58
|
+
metadata,
|
|
59
|
+
policy: isSinglePage ? artifact.policy : import_types.CachePolicy.NetworkOnly,
|
|
60
|
+
session: await getSession()
|
|
61
|
+
},
|
|
62
|
+
isSinglePage ? [] : [where === "start" ? "prepend" : "append"]
|
|
63
|
+
);
|
|
64
|
+
};
|
|
65
|
+
const getPageInfo = () => {
|
|
66
|
+
return (0, import_pageInfo.extractPageInfo)(getState(), artifact.refetch?.path ?? []);
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
loadNextPage: async ({
|
|
70
|
+
first,
|
|
71
|
+
after,
|
|
72
|
+
fetch,
|
|
73
|
+
metadata
|
|
74
|
+
} = {}) => {
|
|
75
|
+
const currentPageInfo = getPageInfo();
|
|
76
|
+
if (!currentPageInfo.hasNextPage) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const input = {
|
|
80
|
+
first: first ?? artifact.refetch.pageSize,
|
|
81
|
+
after: after ?? currentPageInfo.endCursor,
|
|
82
|
+
before: null,
|
|
83
|
+
last: null
|
|
84
|
+
};
|
|
85
|
+
return await loadPage({
|
|
86
|
+
pageSizeVar: "first",
|
|
87
|
+
functionName: "loadNextPage",
|
|
88
|
+
input,
|
|
89
|
+
fetch,
|
|
90
|
+
metadata,
|
|
91
|
+
where: "end"
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
loadPreviousPage: async ({
|
|
95
|
+
last,
|
|
96
|
+
before,
|
|
97
|
+
fetch,
|
|
98
|
+
metadata
|
|
99
|
+
} = {}) => {
|
|
100
|
+
const currentPageInfo = getPageInfo();
|
|
101
|
+
if (!currentPageInfo.hasPreviousPage) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const input = {
|
|
105
|
+
before: before ?? currentPageInfo.startCursor,
|
|
106
|
+
last: last ?? artifact.refetch.pageSize,
|
|
107
|
+
first: null,
|
|
108
|
+
after: null
|
|
109
|
+
};
|
|
110
|
+
return await loadPage({
|
|
111
|
+
pageSizeVar: "last",
|
|
112
|
+
functionName: "loadPreviousPage",
|
|
113
|
+
input,
|
|
114
|
+
fetch,
|
|
115
|
+
metadata,
|
|
116
|
+
where: "start"
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
async fetch(args) {
|
|
120
|
+
const { variables } = args ?? {};
|
|
121
|
+
if (variables && !(0, import_deepEquals.deepEquals)(getVariables(), variables)) {
|
|
122
|
+
return await parentFetch(args);
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
var currentPageInfo = (0, import_pageInfo.extractPageInfo)(getState(), artifact.refetch.path);
|
|
126
|
+
} catch {
|
|
127
|
+
return await parentFetch(args);
|
|
128
|
+
}
|
|
129
|
+
const queryVariables = {};
|
|
130
|
+
const count = (0, import_pageInfo.countPage)(artifact.refetch.path.concat("edges"), getState()) || artifact.refetch.pageSize;
|
|
131
|
+
if (count && count > artifact.refetch.pageSize) {
|
|
132
|
+
if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
|
|
133
|
+
console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
|
|
134
|
+
Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
|
|
135
|
+
`);
|
|
136
|
+
}
|
|
137
|
+
if (!currentPageInfo.hasPreviousPage) {
|
|
138
|
+
queryVariables["first"] = count;
|
|
139
|
+
queryVariables["after"] = null;
|
|
140
|
+
queryVariables["last"] = null;
|
|
141
|
+
queryVariables["before"] = null;
|
|
142
|
+
} else if (!currentPageInfo.hasNextPage) {
|
|
143
|
+
queryVariables["last"] = count;
|
|
144
|
+
queryVariables["first"] = null;
|
|
145
|
+
queryVariables["after"] = null;
|
|
146
|
+
queryVariables["before"] = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
Object.assign(queryVariables, variables ?? {});
|
|
150
|
+
const result = await parentFetch({
|
|
151
|
+
...args,
|
|
152
|
+
variables: queryVariables
|
|
153
|
+
});
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function offsetHandlers({
|
|
159
|
+
artifact,
|
|
160
|
+
storeName,
|
|
161
|
+
getState,
|
|
162
|
+
getVariables,
|
|
163
|
+
fetch: parentFetch,
|
|
164
|
+
fetchUpdate: parentFetchUpdate,
|
|
165
|
+
getSession
|
|
166
|
+
}) {
|
|
167
|
+
let getOffset = () => artifact.refetch?.start || (0, import_pageInfo.countPage)(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
|
|
168
|
+
let currentOffset = getOffset() ?? 0;
|
|
169
|
+
return {
|
|
170
|
+
loadNextPage: async ({
|
|
171
|
+
limit,
|
|
172
|
+
offset,
|
|
173
|
+
fetch,
|
|
174
|
+
metadata
|
|
175
|
+
} = {}) => {
|
|
176
|
+
const queryVariables = {
|
|
177
|
+
...getVariables(),
|
|
178
|
+
offset: offset ?? getOffset()
|
|
179
|
+
};
|
|
180
|
+
if (limit || limit === 0) {
|
|
181
|
+
queryVariables.limit = limit;
|
|
182
|
+
}
|
|
183
|
+
if (!queryVariables.limit && !artifact.refetch.pageSize) {
|
|
184
|
+
throw (0, import_pageInfo.missingPageSizeError)("loadNextPage");
|
|
185
|
+
}
|
|
186
|
+
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
187
|
+
const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
|
|
188
|
+
await targetFetch({
|
|
189
|
+
variables: queryVariables,
|
|
190
|
+
fetch,
|
|
191
|
+
metadata,
|
|
192
|
+
policy: isSinglePage ? artifact.policy : import_types.CachePolicy.NetworkOnly,
|
|
193
|
+
session: await getSession()
|
|
194
|
+
});
|
|
195
|
+
const pageSize = queryVariables.limit || artifact.refetch.pageSize;
|
|
196
|
+
currentOffset = offset + pageSize;
|
|
197
|
+
},
|
|
198
|
+
async fetch(params = {}) {
|
|
199
|
+
const { variables } = params;
|
|
200
|
+
if (variables && !(0, import_deepEquals.deepEquals)(getVariables(), variables)) {
|
|
201
|
+
return parentFetch.call(this, params);
|
|
202
|
+
}
|
|
203
|
+
const count = currentOffset || getOffset();
|
|
204
|
+
const queryVariables = {};
|
|
205
|
+
if (!artifact.refetch.pageSize || count > artifact.refetch.pageSize) {
|
|
206
|
+
queryVariables.limit = count;
|
|
207
|
+
}
|
|
208
|
+
return await parentFetch.call(this, {
|
|
209
|
+
...params,
|
|
210
|
+
variables: queryVariables
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
216
|
+
0 && (module.exports = {
|
|
217
|
+
cursorHandlers,
|
|
218
|
+
offsetHandlers
|
|
219
|
+
});
|
|
@@ -37,7 +37,7 @@ async function marshalSelection({
|
|
|
37
37
|
if (Array.isArray(data)) {
|
|
38
38
|
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
39
39
|
}
|
|
40
|
-
const targetSelection = (0, import_selection.getFieldsForType)(selection, data["__typename"]);
|
|
40
|
+
const targetSelection = (0, import_selection.getFieldsForType)(selection, data["__typename"], false);
|
|
41
41
|
return Object.fromEntries(
|
|
42
42
|
await Promise.all(
|
|
43
43
|
Object.entries(data).map(async ([fieldName, value]) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SubscriptionSelection } from './types';
|
|
2
|
-
export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null): Required<SubscriptionSelection>['fields'];
|
|
2
|
+
export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null, loading: boolean): Required<SubscriptionSelection>['fields'];
|
|
@@ -21,7 +21,15 @@ __export(selection_exports, {
|
|
|
21
21
|
getFieldsForType: () => getFieldsForType
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(selection_exports);
|
|
24
|
-
function getFieldsForType(selection, __typename) {
|
|
24
|
+
function getFieldsForType(selection, __typename, loading) {
|
|
25
|
+
if (loading) {
|
|
26
|
+
if (selection.loadingTypes && selection.loadingTypes.length > 0) {
|
|
27
|
+
return deepMerge(
|
|
28
|
+
...selection.loadingTypes.map((type) => selection.abstractFields?.fields[type])
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return selection.fields ?? {};
|
|
32
|
+
}
|
|
25
33
|
let targetSelection = selection.fields || {};
|
|
26
34
|
if (selection.abstractFields && __typename) {
|
|
27
35
|
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
@@ -33,6 +41,25 @@ function getFieldsForType(selection, __typename) {
|
|
|
33
41
|
}
|
|
34
42
|
return targetSelection;
|
|
35
43
|
}
|
|
44
|
+
function deepMerge(...objects) {
|
|
45
|
+
const mergedObj = {};
|
|
46
|
+
for (let obj of objects) {
|
|
47
|
+
if (!obj) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
for (let prop in obj) {
|
|
51
|
+
if (prop in obj) {
|
|
52
|
+
const val = obj[prop];
|
|
53
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val)) {
|
|
54
|
+
mergedObj[prop] = deepMerge(mergedObj[prop] || {}, val);
|
|
55
|
+
} else {
|
|
56
|
+
mergedObj[prop] = val;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return mergedObj;
|
|
62
|
+
}
|
|
36
63
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
64
|
0 && (module.exports = {
|
|
38
65
|
getFieldsForType
|
|
@@ -25,6 +25,7 @@ declare global {
|
|
|
25
25
|
};
|
|
26
26
|
optimisticResponse?: GraphQLObject;
|
|
27
27
|
parentID?: string;
|
|
28
|
+
silenceLoading?: boolean;
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -52,9 +53,12 @@ export type CompiledDocumentKind = ArtifactKinds;
|
|
|
52
53
|
export type QueryArtifact = BaseCompiledDocument<'HoudiniQuery'> & {
|
|
53
54
|
policy?: CachePolicies;
|
|
54
55
|
partial?: boolean;
|
|
56
|
+
enableLoadingState?: 'global' | 'local';
|
|
55
57
|
};
|
|
56
58
|
export type MutationArtifact = BaseCompiledDocument<'HoudiniMutation'>;
|
|
57
|
-
export type FragmentArtifact = BaseCompiledDocument<'HoudiniFragment'
|
|
59
|
+
export type FragmentArtifact = BaseCompiledDocument<'HoudiniFragment'> & {
|
|
60
|
+
enableLoadingState?: 'global' | 'local';
|
|
61
|
+
};
|
|
58
62
|
export type SubscriptionArtifact = BaseCompiledDocument<'HoudiniSubscription'>;
|
|
59
63
|
export declare const RefetchUpdateMode: {
|
|
60
64
|
readonly append: "append";
|
|
@@ -128,12 +132,34 @@ export type GraphQLObject = {
|
|
|
128
132
|
[key: string]: GraphQLValue;
|
|
129
133
|
};
|
|
130
134
|
export type GraphQLValue = number | string | boolean | null | GraphQLObject | GraphQLValue[] | undefined;
|
|
135
|
+
export type GraphQLVariables = {
|
|
136
|
+
[key: string]: any;
|
|
137
|
+
} | null;
|
|
138
|
+
export type LoadingSpec = {
|
|
139
|
+
kind: 'continue';
|
|
140
|
+
list?: {
|
|
141
|
+
depth: number;
|
|
142
|
+
count: number;
|
|
143
|
+
};
|
|
144
|
+
} | {
|
|
145
|
+
kind: 'value';
|
|
146
|
+
value?: any;
|
|
147
|
+
list?: {
|
|
148
|
+
depth: number;
|
|
149
|
+
count: number;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
131
152
|
export type SubscriptionSelection = {
|
|
132
|
-
|
|
153
|
+
loadingTypes?: string[];
|
|
154
|
+
fragments?: Record<string, {
|
|
155
|
+
arguments: ValueMap;
|
|
156
|
+
loading?: boolean;
|
|
157
|
+
}>;
|
|
133
158
|
fields?: {
|
|
134
159
|
[fieldName: string]: {
|
|
135
160
|
type: string;
|
|
136
161
|
nullable?: boolean;
|
|
162
|
+
required?: boolean;
|
|
137
163
|
keyRaw: string;
|
|
138
164
|
operations?: MutationOperation[];
|
|
139
165
|
list?: {
|
|
@@ -141,6 +167,7 @@ export type SubscriptionSelection = {
|
|
|
141
167
|
connection: boolean;
|
|
142
168
|
type: string;
|
|
143
169
|
};
|
|
170
|
+
loading?: LoadingSpec;
|
|
144
171
|
directives?: {
|
|
145
172
|
name: string;
|
|
146
173
|
arguments: ValueMap;
|
|
@@ -153,6 +180,7 @@ export type SubscriptionSelection = {
|
|
|
153
180
|
}>;
|
|
154
181
|
selection?: SubscriptionSelection;
|
|
155
182
|
abstract?: boolean;
|
|
183
|
+
abstractHasRequired?: boolean;
|
|
156
184
|
};
|
|
157
185
|
};
|
|
158
186
|
abstractFields?: {
|
|
@@ -175,7 +203,7 @@ export type FetchQueryResult<_Data> = {
|
|
|
175
203
|
result: RequestPayload<_Data | null>;
|
|
176
204
|
source: DataSources | null;
|
|
177
205
|
};
|
|
178
|
-
export type QueryResult<_Data = GraphQLObject, _Input =
|
|
206
|
+
export type QueryResult<_Data = GraphQLObject, _Input = GraphQLVariables> = {
|
|
179
207
|
data: _Data | null;
|
|
180
208
|
errors: {
|
|
181
209
|
message: string;
|
|
@@ -194,9 +222,54 @@ export type RequestPayload<GraphQLObject = any> = {
|
|
|
194
222
|
};
|
|
195
223
|
export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
|
|
196
224
|
export type ValueOf<Parent> = Parent[keyof Parent];
|
|
197
|
-
export declare const fragmentKey
|
|
225
|
+
export declare const fragmentKey: " $fragments";
|
|
198
226
|
export type ValueNode = VariableNode | IntValueNode | FloatValueNode | StringValueNode | BooleanValueNode | NullValueNode | EnumValueNode | ListValueNode | ObjectValueNode;
|
|
199
227
|
export type ValueMap = Record<string, ValueNode>;
|
|
228
|
+
export type FetchParams<_Input> = {
|
|
229
|
+
variables?: _Input;
|
|
230
|
+
/**
|
|
231
|
+
* The policy to use when performing the fetch. If set to CachePolicy.NetworkOnly,
|
|
232
|
+
* a request will always be sent, even if the variables are the same as the last call
|
|
233
|
+
* to fetch.
|
|
234
|
+
*/
|
|
235
|
+
policy?: CachePolicies;
|
|
236
|
+
/**
|
|
237
|
+
* An object that will be passed to the fetch function.
|
|
238
|
+
* You can do what you want with it!
|
|
239
|
+
*/
|
|
240
|
+
metadata?: App.Metadata;
|
|
241
|
+
};
|
|
242
|
+
export type FetchFn<_Data extends GraphQLObject, _Input = any> = (params?: FetchParams<_Input>) => Promise<QueryResult<_Data, _Input>>;
|
|
243
|
+
export type CursorHandlers<_Data extends GraphQLObject, _Input> = {
|
|
244
|
+
loadNextPage: (args?: {
|
|
245
|
+
first?: number;
|
|
246
|
+
after?: string;
|
|
247
|
+
fetch?: typeof globalThis.fetch;
|
|
248
|
+
metadata?: {};
|
|
249
|
+
}) => Promise<void>;
|
|
250
|
+
loadPreviousPage: (args?: {
|
|
251
|
+
last?: number;
|
|
252
|
+
before?: string;
|
|
253
|
+
fetch?: typeof globalThis.fetch;
|
|
254
|
+
metadata?: {};
|
|
255
|
+
}) => Promise<void>;
|
|
256
|
+
fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
257
|
+
};
|
|
258
|
+
export type OffsetHandlers<_Data extends GraphQLObject, _Input> = {
|
|
259
|
+
loadNextPage: (args?: {
|
|
260
|
+
limit?: number;
|
|
261
|
+
offset?: number;
|
|
262
|
+
metadata?: {};
|
|
263
|
+
fetch?: typeof globalThis.fetch;
|
|
264
|
+
}) => Promise<void>;
|
|
265
|
+
fetch(args?: FetchParams<_Input> | undefined): Promise<QueryResult<_Data, _Input>>;
|
|
266
|
+
};
|
|
267
|
+
export type PageInfo = {
|
|
268
|
+
startCursor: string | null;
|
|
269
|
+
endCursor: string | null;
|
|
270
|
+
hasNextPage: boolean;
|
|
271
|
+
hasPreviousPage: boolean;
|
|
272
|
+
};
|
|
200
273
|
interface IntValueNode {
|
|
201
274
|
readonly kind: 'IntValue';
|
|
202
275
|
readonly value: string;
|
|
@@ -241,4 +314,6 @@ interface VariableNode {
|
|
|
241
314
|
readonly kind: 'Variable';
|
|
242
315
|
readonly name: NameNode;
|
|
243
316
|
}
|
|
317
|
+
export declare const PendingValue: unique symbol;
|
|
318
|
+
export type LoadingType = typeof PendingValue;
|
|
244
319
|
export {};
|
|
@@ -26,6 +26,7 @@ __export(types_exports, {
|
|
|
26
26
|
CompiledSubscriptionKind: () => CompiledSubscriptionKind,
|
|
27
27
|
DataSource: () => DataSource,
|
|
28
28
|
PaginateMode: () => PaginateMode,
|
|
29
|
+
PendingValue: () => PendingValue,
|
|
29
30
|
RefetchUpdateMode: () => RefetchUpdateMode,
|
|
30
31
|
fragmentKey: () => fragmentKey
|
|
31
32
|
});
|
|
@@ -61,6 +62,7 @@ const DataSource = {
|
|
|
61
62
|
Ssr: "ssr"
|
|
62
63
|
};
|
|
63
64
|
const fragmentKey = " $fragments";
|
|
65
|
+
const PendingValue = Symbol("houdini_loading");
|
|
64
66
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
67
|
0 && (module.exports = {
|
|
66
68
|
ArtifactKind,
|
|
@@ -71,6 +73,7 @@ const fragmentKey = " $fragments";
|
|
|
71
73
|
CompiledSubscriptionKind,
|
|
72
74
|
DataSource,
|
|
73
75
|
PaginateMode,
|
|
76
|
+
PendingValue,
|
|
74
77
|
RefetchUpdateMode,
|
|
75
78
|
fragmentKey
|
|
76
79
|
});
|
|
@@ -3,7 +3,6 @@ import type { GraphQLObject, GraphQLValue, NestedList, SubscriptionSelection, Su
|
|
|
3
3
|
import { GarbageCollector } from './gc';
|
|
4
4
|
import type { ListCollection } from './lists';
|
|
5
5
|
import { ListManager } from './lists';
|
|
6
|
-
import { SchemaManager } from './schema';
|
|
7
6
|
import { StaleManager } from './staleManager';
|
|
8
7
|
import type { Layer, LayerID } from './storage';
|
|
9
8
|
import { InMemoryStorage } from './storage';
|
|
@@ -57,15 +56,13 @@ declare class CacheInternal {
|
|
|
57
56
|
cache: Cache;
|
|
58
57
|
lifetimes: GarbageCollector;
|
|
59
58
|
staleManager: StaleManager;
|
|
60
|
-
|
|
61
|
-
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, schema, disabled, config, }: {
|
|
59
|
+
constructor({ storage, subscriptions, lists, cache, lifetimes, staleManager, disabled, config, }: {
|
|
62
60
|
storage: InMemoryStorage;
|
|
63
61
|
subscriptions: InMemorySubscriptions;
|
|
64
62
|
lists: ListManager;
|
|
65
63
|
cache: Cache;
|
|
66
64
|
lifetimes: GarbageCollector;
|
|
67
65
|
staleManager: StaleManager;
|
|
68
|
-
schema: SchemaManager;
|
|
69
66
|
disabled: boolean;
|
|
70
67
|
config?: ConfigFile;
|
|
71
68
|
});
|
|
@@ -87,12 +84,13 @@ declare class CacheInternal {
|
|
|
87
84
|
forceNotify?: boolean;
|
|
88
85
|
forceStale?: boolean;
|
|
89
86
|
}): FieldSelection[];
|
|
90
|
-
getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, fullCheck, }: {
|
|
87
|
+
getSelection({ selection, parent, variables, stepsFromConnection, ignoreMasking, fullCheck, loading: generateLoading, }: {
|
|
91
88
|
selection: SubscriptionSelection;
|
|
92
89
|
parent?: string;
|
|
93
|
-
variables?: {};
|
|
90
|
+
variables?: {} | null;
|
|
94
91
|
stepsFromConnection?: number | null;
|
|
95
92
|
ignoreMasking?: boolean;
|
|
93
|
+
loading?: boolean;
|
|
96
94
|
fullCheck?: boolean;
|
|
97
95
|
}): {
|
|
98
96
|
data: GraphQLObject | null;
|
|
@@ -104,13 +102,14 @@ declare class CacheInternal {
|
|
|
104
102
|
id(type: string, id: string): string | null;
|
|
105
103
|
idFields(type: string): string[];
|
|
106
104
|
computeID(type: string, data: any): string;
|
|
107
|
-
hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, fullCheck, }: {
|
|
105
|
+
hydrateNestedList({ fields, variables, linkedList, stepsFromConnection, ignoreMasking, fullCheck, loading, }: {
|
|
108
106
|
fields: SubscriptionSelection;
|
|
109
|
-
variables?: {};
|
|
107
|
+
variables?: {} | null;
|
|
110
108
|
linkedList: NestedList;
|
|
111
109
|
stepsFromConnection: number | null;
|
|
112
110
|
ignoreMasking: boolean;
|
|
113
111
|
fullCheck?: boolean;
|
|
112
|
+
loading?: boolean;
|
|
114
113
|
}): {
|
|
115
114
|
data: NestedList<GraphQLValue>;
|
|
116
115
|
partial: boolean;
|