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,52 @@
|
|
|
1
|
+
import { siteURL } from "./constants";
|
|
2
|
+
function nullPageInfo() {
|
|
3
|
+
return { startCursor: null, endCursor: null, hasNextPage: false, hasPreviousPage: false };
|
|
4
|
+
}
|
|
5
|
+
function missingPageSizeError(fnName) {
|
|
6
|
+
return {
|
|
7
|
+
message: `${fnName} is missing the required page arguments. For more information, please visit this link: ${siteURL}/guides/pagination`
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function extractPageInfo(data, path) {
|
|
11
|
+
if (!data) {
|
|
12
|
+
return {
|
|
13
|
+
startCursor: null,
|
|
14
|
+
endCursor: null,
|
|
15
|
+
hasNextPage: false,
|
|
16
|
+
hasPreviousPage: false
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
let localPath = [...path];
|
|
20
|
+
let current = data;
|
|
21
|
+
while (localPath.length > 0) {
|
|
22
|
+
if (!current) {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
current = current[localPath.shift()];
|
|
26
|
+
}
|
|
27
|
+
return current?.pageInfo ?? nullPageInfo();
|
|
28
|
+
}
|
|
29
|
+
function countPage(source, value) {
|
|
30
|
+
let data = value;
|
|
31
|
+
if (value === null || data === null || data === void 0) {
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
for (const field of source) {
|
|
35
|
+
const obj = data[field];
|
|
36
|
+
if (obj && !Array.isArray(obj)) {
|
|
37
|
+
data = obj;
|
|
38
|
+
} else if (!data) {
|
|
39
|
+
throw new Error("Could not count page size");
|
|
40
|
+
}
|
|
41
|
+
if (Array.isArray(obj)) {
|
|
42
|
+
return obj.length;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
countPage,
|
|
49
|
+
extractPageInfo,
|
|
50
|
+
missingPageSizeError,
|
|
51
|
+
nullPageInfo
|
|
52
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SendParams } from '../client/documentStore';
|
|
2
|
+
import type { CursorHandlers, FetchFn, GraphQLObject, GraphQLVariables, QueryArtifact, QueryResult, FetchParams } from './types';
|
|
3
|
+
export declare function cursorHandlers<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ artifact, fetchUpdate: parentFetchUpdate, fetch: parentFetch, getState, getVariables, getSession, }: {
|
|
4
|
+
artifact: QueryArtifact;
|
|
5
|
+
getState: () => _Data | null;
|
|
6
|
+
getVariables: () => NonNullable<_Input>;
|
|
7
|
+
getSession: () => Promise<App.Session>;
|
|
8
|
+
fetch: FetchFn<_Data, _Input>;
|
|
9
|
+
fetchUpdate: (arg: SendParams, updates: string[]) => ReturnType<FetchFn<_Data, _Input>>;
|
|
10
|
+
}): CursorHandlers<_Data, _Input>;
|
|
11
|
+
export declare function offsetHandlers<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ artifact, storeName, getState, getVariables, fetch: parentFetch, fetchUpdate: parentFetchUpdate, getSession, }: {
|
|
12
|
+
artifact: QueryArtifact;
|
|
13
|
+
fetch: FetchFn<_Data, _Input>;
|
|
14
|
+
fetchUpdate: (arg: SendParams) => ReturnType<FetchFn<_Data, _Input>>;
|
|
15
|
+
storeName: string;
|
|
16
|
+
getState: () => _Data | null;
|
|
17
|
+
getVariables: () => _Input;
|
|
18
|
+
getSession: () => Promise<App.Session>;
|
|
19
|
+
}): {
|
|
20
|
+
loadNextPage: ({ limit, offset, fetch, metadata, }?: {
|
|
21
|
+
limit?: number | undefined;
|
|
22
|
+
offset?: number | undefined;
|
|
23
|
+
fetch?: typeof fetch | undefined;
|
|
24
|
+
metadata?: {} | undefined;
|
|
25
|
+
}) => Promise<void>;
|
|
26
|
+
fetch(params?: FetchParams<_Input>): Promise<QueryResult<_Data, _Input>>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { getCurrentConfig } from "./config";
|
|
2
|
+
import { deepEquals } from "./deepEquals";
|
|
3
|
+
import { countPage, extractPageInfo, missingPageSizeError } from "./pageInfo";
|
|
4
|
+
import { CachePolicy } from "./types";
|
|
5
|
+
function cursorHandlers({
|
|
6
|
+
artifact,
|
|
7
|
+
fetchUpdate: parentFetchUpdate,
|
|
8
|
+
fetch: parentFetch,
|
|
9
|
+
getState,
|
|
10
|
+
getVariables,
|
|
11
|
+
getSession
|
|
12
|
+
}) {
|
|
13
|
+
const loadPage = async ({
|
|
14
|
+
pageSizeVar,
|
|
15
|
+
input,
|
|
16
|
+
functionName,
|
|
17
|
+
metadata = {},
|
|
18
|
+
fetch,
|
|
19
|
+
where
|
|
20
|
+
}) => {
|
|
21
|
+
const config = getCurrentConfig();
|
|
22
|
+
const loadVariables = {
|
|
23
|
+
...getVariables(),
|
|
24
|
+
...input
|
|
25
|
+
};
|
|
26
|
+
if (!loadVariables[pageSizeVar] && !artifact.refetch.pageSize) {
|
|
27
|
+
throw missingPageSizeError(functionName);
|
|
28
|
+
}
|
|
29
|
+
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
30
|
+
await (isSinglePage ? parentFetch : parentFetchUpdate)(
|
|
31
|
+
{
|
|
32
|
+
variables: loadVariables,
|
|
33
|
+
fetch,
|
|
34
|
+
metadata,
|
|
35
|
+
policy: isSinglePage ? artifact.policy : CachePolicy.NetworkOnly,
|
|
36
|
+
session: await getSession()
|
|
37
|
+
},
|
|
38
|
+
isSinglePage ? [] : [where === "start" ? "prepend" : "append"]
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
const getPageInfo = () => {
|
|
42
|
+
return extractPageInfo(getState(), artifact.refetch?.path ?? []);
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
loadNextPage: async ({
|
|
46
|
+
first,
|
|
47
|
+
after,
|
|
48
|
+
fetch,
|
|
49
|
+
metadata
|
|
50
|
+
} = {}) => {
|
|
51
|
+
const currentPageInfo = getPageInfo();
|
|
52
|
+
if (!currentPageInfo.hasNextPage) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const input = {
|
|
56
|
+
first: first ?? artifact.refetch.pageSize,
|
|
57
|
+
after: after ?? currentPageInfo.endCursor,
|
|
58
|
+
before: null,
|
|
59
|
+
last: null
|
|
60
|
+
};
|
|
61
|
+
return await loadPage({
|
|
62
|
+
pageSizeVar: "first",
|
|
63
|
+
functionName: "loadNextPage",
|
|
64
|
+
input,
|
|
65
|
+
fetch,
|
|
66
|
+
metadata,
|
|
67
|
+
where: "end"
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
loadPreviousPage: async ({
|
|
71
|
+
last,
|
|
72
|
+
before,
|
|
73
|
+
fetch,
|
|
74
|
+
metadata
|
|
75
|
+
} = {}) => {
|
|
76
|
+
const currentPageInfo = getPageInfo();
|
|
77
|
+
if (!currentPageInfo.hasPreviousPage) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const input = {
|
|
81
|
+
before: before ?? currentPageInfo.startCursor,
|
|
82
|
+
last: last ?? artifact.refetch.pageSize,
|
|
83
|
+
first: null,
|
|
84
|
+
after: null
|
|
85
|
+
};
|
|
86
|
+
return await loadPage({
|
|
87
|
+
pageSizeVar: "last",
|
|
88
|
+
functionName: "loadPreviousPage",
|
|
89
|
+
input,
|
|
90
|
+
fetch,
|
|
91
|
+
metadata,
|
|
92
|
+
where: "start"
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
async fetch(args) {
|
|
96
|
+
const { variables } = args ?? {};
|
|
97
|
+
if (variables && !deepEquals(getVariables(), variables)) {
|
|
98
|
+
return await parentFetch(args);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
var currentPageInfo = extractPageInfo(getState(), artifact.refetch.path);
|
|
102
|
+
} catch {
|
|
103
|
+
return await parentFetch(args);
|
|
104
|
+
}
|
|
105
|
+
const queryVariables = {};
|
|
106
|
+
const count = countPage(artifact.refetch.path.concat("edges"), getState()) || artifact.refetch.pageSize;
|
|
107
|
+
if (count && count > artifact.refetch.pageSize) {
|
|
108
|
+
if (currentPageInfo.hasPreviousPage && currentPageInfo.hasNextPage && !(variables?.["first"] && variables?.["after"] || variables?.["last"] && variables?.["before"])) {
|
|
109
|
+
console.warn(`\u26A0\uFE0F Encountered a fetch() in the middle of the connection.
|
|
110
|
+
Make sure to pass a cursor value by hand that includes the current set (ie the entry before startCursor)
|
|
111
|
+
`);
|
|
112
|
+
}
|
|
113
|
+
if (!currentPageInfo.hasPreviousPage) {
|
|
114
|
+
queryVariables["first"] = count;
|
|
115
|
+
queryVariables["after"] = null;
|
|
116
|
+
queryVariables["last"] = null;
|
|
117
|
+
queryVariables["before"] = null;
|
|
118
|
+
} else if (!currentPageInfo.hasNextPage) {
|
|
119
|
+
queryVariables["last"] = count;
|
|
120
|
+
queryVariables["first"] = null;
|
|
121
|
+
queryVariables["after"] = null;
|
|
122
|
+
queryVariables["before"] = null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
Object.assign(queryVariables, variables ?? {});
|
|
126
|
+
const result = await parentFetch({
|
|
127
|
+
...args,
|
|
128
|
+
variables: queryVariables
|
|
129
|
+
});
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function offsetHandlers({
|
|
135
|
+
artifact,
|
|
136
|
+
storeName,
|
|
137
|
+
getState,
|
|
138
|
+
getVariables,
|
|
139
|
+
fetch: parentFetch,
|
|
140
|
+
fetchUpdate: parentFetchUpdate,
|
|
141
|
+
getSession
|
|
142
|
+
}) {
|
|
143
|
+
let getOffset = () => artifact.refetch?.start || countPage(artifact.refetch.path, getState()) || artifact.refetch.pageSize;
|
|
144
|
+
let currentOffset = getOffset() ?? 0;
|
|
145
|
+
return {
|
|
146
|
+
loadNextPage: async ({
|
|
147
|
+
limit,
|
|
148
|
+
offset,
|
|
149
|
+
fetch,
|
|
150
|
+
metadata
|
|
151
|
+
} = {}) => {
|
|
152
|
+
const queryVariables = {
|
|
153
|
+
...getVariables(),
|
|
154
|
+
offset: offset ?? getOffset()
|
|
155
|
+
};
|
|
156
|
+
if (limit || limit === 0) {
|
|
157
|
+
queryVariables.limit = limit;
|
|
158
|
+
}
|
|
159
|
+
if (!queryVariables.limit && !artifact.refetch.pageSize) {
|
|
160
|
+
throw missingPageSizeError("loadNextPage");
|
|
161
|
+
}
|
|
162
|
+
let isSinglePage = artifact.refetch?.mode === "SinglePage";
|
|
163
|
+
const targetFetch = isSinglePage ? parentFetch : parentFetchUpdate;
|
|
164
|
+
await targetFetch({
|
|
165
|
+
variables: queryVariables,
|
|
166
|
+
fetch,
|
|
167
|
+
metadata,
|
|
168
|
+
policy: isSinglePage ? artifact.policy : CachePolicy.NetworkOnly,
|
|
169
|
+
session: await getSession()
|
|
170
|
+
});
|
|
171
|
+
const pageSize = queryVariables.limit || artifact.refetch.pageSize;
|
|
172
|
+
currentOffset = offset + pageSize;
|
|
173
|
+
},
|
|
174
|
+
async fetch(params = {}) {
|
|
175
|
+
const { variables } = params;
|
|
176
|
+
if (variables && !deepEquals(getVariables(), variables)) {
|
|
177
|
+
return parentFetch.call(this, params);
|
|
178
|
+
}
|
|
179
|
+
const count = currentOffset || getOffset();
|
|
180
|
+
const queryVariables = {};
|
|
181
|
+
if (!artifact.refetch.pageSize || count > artifact.refetch.pageSize) {
|
|
182
|
+
queryVariables.limit = count;
|
|
183
|
+
}
|
|
184
|
+
return await parentFetch.call(this, {
|
|
185
|
+
...params,
|
|
186
|
+
variables: queryVariables
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
cursorHandlers,
|
|
193
|
+
offsetHandlers
|
|
194
|
+
};
|
|
@@ -11,7 +11,7 @@ async function marshalSelection({
|
|
|
11
11
|
if (Array.isArray(data)) {
|
|
12
12
|
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
13
13
|
}
|
|
14
|
-
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
14
|
+
const targetSelection = getFieldsForType(selection, data["__typename"], false);
|
|
15
15
|
return Object.fromEntries(
|
|
16
16
|
await Promise.all(
|
|
17
17
|
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'];
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
function getFieldsForType(selection, __typename) {
|
|
1
|
+
function getFieldsForType(selection, __typename, loading) {
|
|
2
|
+
if (loading) {
|
|
3
|
+
if (selection.loadingTypes && selection.loadingTypes.length > 0) {
|
|
4
|
+
return deepMerge(
|
|
5
|
+
...selection.loadingTypes.map((type) => selection.abstractFields?.fields[type])
|
|
6
|
+
);
|
|
7
|
+
}
|
|
8
|
+
return selection.fields ?? {};
|
|
9
|
+
}
|
|
2
10
|
let targetSelection = selection.fields || {};
|
|
3
11
|
if (selection.abstractFields && __typename) {
|
|
4
12
|
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
@@ -10,6 +18,25 @@ function getFieldsForType(selection, __typename) {
|
|
|
10
18
|
}
|
|
11
19
|
return targetSelection;
|
|
12
20
|
}
|
|
21
|
+
function deepMerge(...objects) {
|
|
22
|
+
const mergedObj = {};
|
|
23
|
+
for (let obj of objects) {
|
|
24
|
+
if (!obj) {
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
for (let prop in obj) {
|
|
28
|
+
if (prop in obj) {
|
|
29
|
+
const val = obj[prop];
|
|
30
|
+
if (typeof val === "object" && val !== null && !Array.isArray(val)) {
|
|
31
|
+
mergedObj[prop] = deepMerge(mergedObj[prop] || {}, val);
|
|
32
|
+
} else {
|
|
33
|
+
mergedObj[prop] = val;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return mergedObj;
|
|
39
|
+
}
|
|
13
40
|
export {
|
|
14
41
|
getFieldsForType
|
|
15
42
|
};
|
|
@@ -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 {};
|
|
@@ -29,6 +29,7 @@ const DataSource = {
|
|
|
29
29
|
Ssr: "ssr"
|
|
30
30
|
};
|
|
31
31
|
const fragmentKey = " $fragments";
|
|
32
|
+
const PendingValue = Symbol("houdini_loading");
|
|
32
33
|
export {
|
|
33
34
|
ArtifactKind,
|
|
34
35
|
CachePolicy,
|
|
@@ -38,6 +39,7 @@ export {
|
|
|
38
39
|
CompiledSubscriptionKind,
|
|
39
40
|
DataSource,
|
|
40
41
|
PaginateMode,
|
|
42
|
+
PendingValue,
|
|
41
43
|
RefetchUpdateMode,
|
|
42
44
|
fragmentKey
|
|
43
45
|
};
|
package/build/test/index.d.ts
CHANGED
|
@@ -9,3 +9,18 @@ export type Partial<T> = {
|
|
|
9
9
|
export declare function pipelineTest(config: Config, documents: string[], shouldPass: boolean, testBody?: ((result: Error | Error[]) => void) | ((docs: Document[]) => void)): () => Promise<void>;
|
|
10
10
|
export declare function mockCollectedDoc(query: string, data?: Partial<Document>): Document;
|
|
11
11
|
export declare function clearMock(): void;
|
|
12
|
+
export type Row = {
|
|
13
|
+
title: string;
|
|
14
|
+
pass: true;
|
|
15
|
+
documents: string[];
|
|
16
|
+
check?: (docs: Document[]) => void;
|
|
17
|
+
partial_config?: Partial<Config>;
|
|
18
|
+
nb_of_fail?: number;
|
|
19
|
+
} | {
|
|
20
|
+
title: string;
|
|
21
|
+
pass: false;
|
|
22
|
+
documents: string[];
|
|
23
|
+
check?: (result: Error | Error[]) => void;
|
|
24
|
+
partial_config?: Partial<Config>;
|
|
25
|
+
nb_of_fail?: number;
|
|
26
|
+
};
|