eddev 0.1.41 → 0.1.42
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.
|
@@ -219,10 +219,10 @@ module.exports = {
|
|
|
219
219
|
// Drill down to the path type
|
|
220
220
|
var finalResultTypeName_1 = resultTypeName;
|
|
221
221
|
pageInfo_1.nodesPath.forEach(function (key) {
|
|
222
|
-
finalResultTypeName_1 = "Exclude<".concat(finalResultTypeName_1, "[").concat(JSON.stringify(key), "], null>");
|
|
222
|
+
finalResultTypeName_1 = "Exclude<".concat(finalResultTypeName_1, "[").concat(JSON.stringify(key), "], undefined | null>");
|
|
223
223
|
});
|
|
224
224
|
importUtils["createUseInfiniteQuery"] = true;
|
|
225
|
-
hooks[hookName] = "\n createUseInfiniteQuery<Exclude<".concat(finalResultTypeName_1, "[0], null>, Omit<").concat(variablesTypeName || "undefined", ", 'limit' | 'cursor'>>({\n name: ").concat(JSON.stringify(name), ",\n defaultLimit: ").concat(defaultLimit_1, ",\n paths: ").concat(JSON.stringify(pageInfo_1), "\n })\n ");
|
|
225
|
+
hooks[hookName] = "\n createUseInfiniteQuery<Exclude<".concat(finalResultTypeName_1, "[0], undefined | null>, Omit<").concat(variablesTypeName || "undefined", ", 'limit' | 'cursor'>>({\n name: ").concat(JSON.stringify(name), ",\n defaultLimit: ").concat(defaultLimit_1, ",\n paths: ").concat(JSON.stringify(pageInfo_1), "\n })\n ");
|
|
226
226
|
}
|
|
227
227
|
});
|
|
228
228
|
}
|
|
@@ -293,12 +293,18 @@ function beginWork(opts) {
|
|
|
293
293
|
},
|
|
294
294
|
config: {
|
|
295
295
|
// maybeValue: "T",
|
|
296
|
-
avoidOptionals:
|
|
296
|
+
avoidOptionals: {
|
|
297
|
+
field: true,
|
|
298
|
+
inputValue: false,
|
|
299
|
+
object: true,
|
|
300
|
+
defaultValue: true,
|
|
301
|
+
},
|
|
297
302
|
// exportFragmentSpreadSubTypes: true,
|
|
298
303
|
inlineFragmentTypes: "combine",
|
|
299
304
|
onlyOperationTypes: true,
|
|
300
305
|
skipTypename: true,
|
|
301
306
|
preResolveTypes: true,
|
|
307
|
+
maybeValue: "T | null",
|
|
302
308
|
},
|
|
303
309
|
},
|
|
304
310
|
"types.views.ts": {
|
package/hooks/queryUtils.d.ts
CHANGED
|
@@ -34,9 +34,9 @@ declare type InfiniteQueryHookReturn<TItem, TVars> = {
|
|
|
34
34
|
loadingMore: boolean;
|
|
35
35
|
errors?: GraphQLError[];
|
|
36
36
|
items?: TItem[];
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
refresh: (
|
|
37
|
+
cursor?: string;
|
|
38
|
+
hasMore: boolean;
|
|
39
|
+
refresh: () => void;
|
|
40
40
|
loadMore: () => void;
|
|
41
41
|
};
|
|
42
42
|
declare type InfiniteQueryHasAdditionalVars<TVars> = Exclude<keyof TVars, "limit" | "cursor"> extends never ? false : true;
|
package/hooks/queryUtils.js
CHANGED
|
@@ -112,17 +112,25 @@ function createUseInfiniteQuery(init) {
|
|
|
112
112
|
var _d = (0, react_1.useState)(false), hasMore = _d[0], setHasMore = _d[1];
|
|
113
113
|
var _e = (0, react_1.useState)(true), isLoadingMore = _e[0], setIsLoadingMore = _e[1];
|
|
114
114
|
var _f = (0, react_1.useState)([]), items = _f[0], setItems = _f[1];
|
|
115
|
-
var _g = (0,
|
|
115
|
+
var _g = (0, react_1.useState)(vars), varPayload = _g[0], setVarPayload = _g[1];
|
|
116
|
+
var _h = (0, swr_1.default)([
|
|
116
117
|
init.name,
|
|
117
|
-
JSON.stringify(__assign(__assign({}, (
|
|
118
|
+
JSON.stringify(__assign(__assign({}, (varPayload || {})), { cursor: activeCursor })),
|
|
118
119
|
], fetcherGET, {
|
|
119
120
|
revalidateIfStale: false,
|
|
120
121
|
revalidateOnFocus: false,
|
|
121
122
|
revalidateOnReconnect: false,
|
|
122
|
-
}), payload =
|
|
123
|
+
}), payload = _h.data, isValidating = _h.isValidating, error = _h.error, mutate = _h.mutate;
|
|
124
|
+
(0, react_1.useEffect)(function () {
|
|
125
|
+
setItems([]);
|
|
126
|
+
setIsLoadingMore(true);
|
|
127
|
+
setErrors(undefined);
|
|
128
|
+
setHasMore(false);
|
|
129
|
+
setActiveCursor(undefined);
|
|
130
|
+
setVarPayload(vars);
|
|
131
|
+
}, [JSON.stringify(vars)]);
|
|
123
132
|
(0, react_1.useEffect)(function () {
|
|
124
133
|
if (payload) {
|
|
125
|
-
console.log("Got payload", payload);
|
|
126
134
|
setIsLoadingMore(false);
|
|
127
135
|
if (payload.errors) {
|
|
128
136
|
setErrors(payload.errors);
|
|
@@ -143,6 +151,7 @@ function createUseInfiniteQuery(init) {
|
|
|
143
151
|
loading: isValidating && !items.length,
|
|
144
152
|
loadingMore: isLoadingMore,
|
|
145
153
|
items: items,
|
|
154
|
+
cursor: activeCursor,
|
|
146
155
|
errors: error ? [error] : errors,
|
|
147
156
|
refresh: function () {
|
|
148
157
|
setErrors(undefined);
|