@jobber/hooks 2.6.3-JOB-80005.6 → 2.6.3
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.
|
@@ -56,6 +56,7 @@ function useCollectionQuery({ query, queryOptions, getCollectionByPath, subscrip
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
setLoadingNextPage(true);
|
|
59
|
+
setHookError(undefined);
|
|
59
60
|
fetchMore({
|
|
60
61
|
variables: {
|
|
61
62
|
cursor: pageInfo.endCursor,
|
|
@@ -85,6 +86,8 @@ function useCollectionQuery({ query, queryOptions, getCollectionByPath, subscrip
|
|
|
85
86
|
if (subscription == undefined)
|
|
86
87
|
return;
|
|
87
88
|
const subscriptionOptions = subscription.options || {};
|
|
89
|
+
// Reset this state so we can handle errors from the subscription
|
|
90
|
+
setHookError(undefined);
|
|
88
91
|
return subscribeToMore(Object.assign(Object.assign({}, subscriptionOptions), { document: subscription.document, updateQuery: (prev, { subscriptionData }) => subscribeToMoreHandler(isSearching, prev, getCollectionByPath, subscriptionData === null || subscriptionData === void 0 ? void 0 : subscriptionData.data, subscription.getNodeByPath), onError: err => {
|
|
89
92
|
formatters_1.config.errorNotifier("Subscribe to More Error", err);
|
|
90
93
|
setHookError(err);
|
|
@@ -226,6 +226,7 @@ describe("useCollectionQuery", () => {
|
|
|
226
226
|
},
|
|
227
227
|
error: mockError,
|
|
228
228
|
},
|
|
229
|
+
(0, test_utilities_1.buildListRequestMockForNextPage)(query, responseMock),
|
|
229
230
|
]),
|
|
230
231
|
});
|
|
231
232
|
yield (0, react_hooks_1.act)(test_utilities_1.wait);
|
|
@@ -234,6 +235,12 @@ describe("useCollectionQuery", () => {
|
|
|
234
235
|
});
|
|
235
236
|
yield (0, react_hooks_1.act)(test_utilities_1.wait);
|
|
236
237
|
expect(result.current.error).toEqual(mockError);
|
|
238
|
+
// should clear the error after a successful fetch
|
|
239
|
+
(0, react_hooks_1.act)(() => {
|
|
240
|
+
result.current.nextPage();
|
|
241
|
+
});
|
|
242
|
+
yield (0, react_hooks_1.act)(test_utilities_1.wait);
|
|
243
|
+
expect(result.current.error).toBeUndefined();
|
|
237
244
|
}));
|
|
238
245
|
});
|
|
239
246
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/hooks",
|
|
3
|
-
"version": "2.6.3
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@apollo/react-testing": "^4.0.0",
|
|
23
|
-
"@jobber/formatters": "
|
|
23
|
+
"@jobber/formatters": "*",
|
|
24
24
|
"@testing-library/react": "^14.0.0",
|
|
25
25
|
"@testing-library/react-hooks": "^7.0.0",
|
|
26
26
|
"@testing-library/user-event": "^14.5.1",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"@apollo/client": "^3.0.0",
|
|
46
46
|
"react": "^18"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "6e42ff7d712d09ecd2214b0fccae8c39bc51afec"
|
|
49
49
|
}
|