@txo/service-graphql-react 2.5.22 → 2.6.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/CHANGELOG.md +14 -0
- package/lib/Api/ObservableContext.d.ts +7 -0
- package/lib/Api/ObservableContext.js +11 -0
- package/lib/Api/ObservableContext.js.map +1 -0
- package/lib/Hooks/UseServiceQuery.js +16 -3
- package/lib/Hooks/UseServiceQuery.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/src/Api/ObservableContext.ts +9 -0
- package/src/Hooks/UseServiceQuery.ts +17 -3
- package/src/index.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [2.6.1](https://github.com/technology-studio/service-graphql-react/compare/v2.6.0...v2.6.1) (2024-05-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug fixes
|
|
5
|
+
|
|
6
|
+
* **deps:** update dependency @apollo/client to ^3.10.2 ([d1094d2](https://github.com/technology-studio/service-graphql-react/commit/d1094d2bbc479c22aa3075d18fa292bbed8da780))
|
|
7
|
+
|
|
8
|
+
## [2.6.0](https://github.com/technology-studio/service-graphql-react/compare/v2.5.22...v2.6.0) (2024-05-02)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add observable context to prevent refetching data or updating views when not observed ([#721](https://github.com/technology-studio/service-graphql-react/issues/721)) ([357ca5b](https://github.com/technology-studio/service-graphql-react/commit/357ca5bc9c8431cda7b38b9f63353f2e72aed7f2))
|
|
14
|
+
|
|
1
15
|
## [2.5.22](https://github.com/technology-studio/service-graphql-react/compare/v2.5.21...v2.5.22) (2024-05-01)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @Author: Erik Slovak <erik.slovak@technologystudio.sk>
|
|
4
|
+
* @Date: 2024-04-30T09:31:07+02:00
|
|
5
|
+
* @Copyright: Technology Studio
|
|
6
|
+
**/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ObservableContext = void 0;
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
exports.ObservableContext = (0, react_1.createContext)(true);
|
|
11
|
+
//# sourceMappingURL=ObservableContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ObservableContext.js","sourceRoot":"","sources":["../../src/Api/ObservableContext.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,iCAAqC;AAExB,QAAA,iBAAiB,GAAG,IAAA,qBAAa,EAAU,IAAI,CAAC,CAAA"}
|
|
@@ -19,6 +19,7 @@ const service_error_handler_react_1 = require("@txo-peer-dep/service-error-handl
|
|
|
19
19
|
const ContextHelper_1 = require("../Api/ContextHelper");
|
|
20
20
|
const OperationHelper_1 = require("../Api/OperationHelper");
|
|
21
21
|
const PromiseHelper_1 = require("../Api/PromiseHelper");
|
|
22
|
+
const ObservableContext_1 = require("../Api/ObservableContext");
|
|
22
23
|
const calculateContext = (query, variables) => ((0, ContextHelper_1.serviceContext)((0, OperationHelper_1.getName)(query), variables ?? {}));
|
|
23
24
|
const isServiceErrorListEqual = (a, b) => {
|
|
24
25
|
if (a.length !== b.length) {
|
|
@@ -31,13 +32,24 @@ const isServiceErrorListEqual = (a, b) => {
|
|
|
31
32
|
};
|
|
32
33
|
// TODO: find a better way to parse type of dataPath (from attribute)
|
|
33
34
|
const useServiceQuery = (queryDocument, options) => {
|
|
34
|
-
const { dataPath, options:
|
|
35
|
+
const { dataPath, options: _queryOptions, } = options;
|
|
36
|
+
const observable = (0, react_1.useContext)(ObservableContext_1.ObservableContext);
|
|
37
|
+
const isSkipped = ((_queryOptions?.skip) ?? false) || !observable;
|
|
38
|
+
const queryOptions = (0, hooks_react_1.useMemoObject)({
|
|
39
|
+
..._queryOptions,
|
|
40
|
+
skip: isSkipped,
|
|
41
|
+
});
|
|
35
42
|
const query = (0, client_1.useQuery)(queryDocument, queryOptions);
|
|
36
43
|
const shownExceptionListRef = (0, react_1.useRef)([]);
|
|
37
44
|
const { addServiceErrorException, removeServiceErrorException, } = (0, react_1.useContext)(service_error_handler_react_1.ErrorHandlerContext);
|
|
38
45
|
const [fetchMoreFetching, setFetchMoreFetching] = (0, react_1.useState)(false);
|
|
39
46
|
const memoizedVariables = (0, hooks_react_1.useMemoObject)(queryOptions?.variables);
|
|
40
47
|
const memoizedQuery = (0, hooks_react_1.useMemoObject)(query);
|
|
48
|
+
const recentData = (0, react_1.useRef)(memoizedQuery.data);
|
|
49
|
+
if (!isSkipped) {
|
|
50
|
+
recentData.current = memoizedQuery.data;
|
|
51
|
+
}
|
|
52
|
+
const data = recentData.current ?? null;
|
|
41
53
|
const context = (0, react_1.useMemo)(() => (calculateContext(queryDocument, memoizedVariables)), [queryDocument, memoizedVariables]);
|
|
42
54
|
const exception = (0, react_1.useMemo)(() => {
|
|
43
55
|
const operationName = (0, OperationHelper_1.getName)(queryDocument);
|
|
@@ -90,13 +102,14 @@ const useServiceQuery = (queryDocument, options) => {
|
|
|
90
102
|
}, [addServiceErrorException, context, memoizedQuery, queryDocument, setFetchMoreFetching]);
|
|
91
103
|
return (0, react_1.useMemo)(() => ({
|
|
92
104
|
query: memoizedQuery,
|
|
93
|
-
|
|
105
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
106
|
+
data: (0, lodash_get_1.default)(data, dataPath),
|
|
94
107
|
fetching: memoizedQuery.loading,
|
|
95
108
|
fetchMoreFetching,
|
|
96
109
|
promiselessRefetch,
|
|
97
110
|
fetchMore,
|
|
98
111
|
exception,
|
|
99
|
-
}), [memoizedQuery, dataPath, fetchMoreFetching, promiselessRefetch, fetchMore, exception]);
|
|
112
|
+
}), [memoizedQuery, data, dataPath, fetchMoreFetching, promiselessRefetch, fetchMore, exception]);
|
|
100
113
|
};
|
|
101
114
|
exports.useServiceQuery = useServiceQuery;
|
|
102
115
|
//# sourceMappingURL=UseServiceQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseServiceQuery.js","sourceRoot":"","sources":["../../src/Hooks/UseServiceQuery.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iCAOc;AASd,2CAEuB;AACvB,4DAA4B;AAO5B,oDAE0B;AAC1B,mEAA6D;AAC7D,kDAEyB;AACzB,2FAA+E;AAG/E,wDAAqD;AACrD,4DAAgD;AAChD,wDAAsD;
|
|
1
|
+
{"version":3,"file":"UseServiceQuery.js","sourceRoot":"","sources":["../../src/Hooks/UseServiceQuery.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iCAOc;AASd,2CAEuB;AACvB,4DAA4B;AAO5B,oDAE0B;AAC1B,mEAA6D;AAC7D,kDAEyB;AACzB,2FAA+E;AAG/E,wDAAqD;AACrD,4DAAgD;AAChD,wDAAsD;AACtD,gEAA4D;AAE5D,MAAM,gBAAgB,GAAG,CAAC,KAAmB,EAAE,SAA8C,EAAU,EAAE,CAAC,CACxG,IAAA,8BAAc,EAAC,IAAA,yBAAO,EAAC,KAAK,CAAC,EAAE,SAAS,IAAI,EAAE,CAAC,CAChD,CAAA;AAgBD,MAAM,uBAAuB,GAAG,CAAC,CAAiB,EAAE,CAAiB,EAAW,EAAE;IAChF,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE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AC,IAAI,EAAE,QAAQ,CAAgC;QACxD,QAAQ,EAAE,aAAa,CAAC,OAAO;QAC/B,iBAAiB;QACjB,kBAAkB;QAClB,SAAS;QACT,SAAS;KACV,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAA;AACnG,CAAC,CAAA;AAvGY,QAAA,eAAe,mBAuG3B"}
|
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
**/
|
|
6
6
|
export { getName } from './Api/OperationHelper';
|
|
7
7
|
export * from './Api/ErrorMapHelper';
|
|
8
|
+
export * from './Api/ObservableContext';
|
|
8
9
|
export * from './Api/PromiseHelper';
|
|
9
10
|
export * from './Hooks/UseServiceMutation';
|
|
10
11
|
export { useServiceQuery, type QueryServiceProp, } from './Hooks/UseServiceQuery';
|
package/lib/index.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.useServiceQuery = exports.getName = void 0;
|
|
|
23
23
|
var OperationHelper_1 = require("./Api/OperationHelper");
|
|
24
24
|
Object.defineProperty(exports, "getName", { enumerable: true, get: function () { return OperationHelper_1.getName; } });
|
|
25
25
|
__exportStar(require("./Api/ErrorMapHelper"), exports);
|
|
26
|
+
__exportStar(require("./Api/ObservableContext"), exports);
|
|
26
27
|
__exportStar(require("./Api/PromiseHelper"), exports);
|
|
27
28
|
__exportStar(require("./Hooks/UseServiceMutation"), exports);
|
|
28
29
|
var UseServiceQuery_1 = require("./Hooks/UseServiceQuery");
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,yDAA+C;AAAtC,0GAAA,OAAO,OAAA;AAChB,uDAAoC;AACpC,sDAAmC;AACnC,6DAA0C;AAC1C,2DAGgC;AAF9B,kHAAA,eAAe,OAAA;AAGjB,gDAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,yDAA+C;AAAtC,0GAAA,OAAO,OAAA;AAChB,uDAAoC;AACpC,0DAAuC;AACvC,sDAAmC;AACnC,6DAA0C;AAC1C,2DAGgC;AAF9B,kHAAA,eAAe,OAAA;AAGjB,gDAA6B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@txo/service-graphql-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "Technology Studio - Service graphql react",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -46,19 +46,19 @@
|
|
|
46
46
|
"type-fest": "^4.18.1"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@apollo/client": "^3.10.
|
|
49
|
+
"@apollo/client": "^3.10.2",
|
|
50
50
|
"@txo-peer-dep/service-error-handler-react": "^1.2.29",
|
|
51
51
|
"@txo-peer-dep/service-graphql": "^3.3.3",
|
|
52
52
|
"graphql": "^16.8.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@apollo/client": "^3.10.
|
|
55
|
+
"@apollo/client": "^3.10.2",
|
|
56
56
|
"@txo-peer-dep/log": "^4.0.4",
|
|
57
57
|
"@txo-peer-dep/service-error-handler-react": "^1.2.29",
|
|
58
58
|
"@txo-peer-dep/service-graphql": "^3.3.3",
|
|
59
|
-
"@txo/commitlint": "^1.0.
|
|
59
|
+
"@txo/commitlint": "^1.0.15",
|
|
60
60
|
"@txo/log-console": "^3.0.0",
|
|
61
|
-
"@txo/semantic-release": "^
|
|
61
|
+
"@txo/semantic-release": "^2.0.8",
|
|
62
62
|
"@txo/tsconfig": "^1.1.1",
|
|
63
63
|
"@types/jest": "^29.5.12",
|
|
64
64
|
"@types/lodash.get": "^4.4.9",
|
|
@@ -43,6 +43,7 @@ import type { Typify } from '@txo/types'
|
|
|
43
43
|
import { serviceContext } from '../Api/ContextHelper'
|
|
44
44
|
import { getName } from '../Api/OperationHelper'
|
|
45
45
|
import { asyncToCallback } from '../Api/PromiseHelper'
|
|
46
|
+
import { ObservableContext } from '../Api/ObservableContext'
|
|
46
47
|
|
|
47
48
|
const calculateContext = (query: DocumentNode, variables: Record<string, unknown> | undefined): string => (
|
|
48
49
|
serviceContext(getName(query), variables ?? {})
|
|
@@ -84,8 +85,15 @@ export const useServiceQuery = <
|
|
|
84
85
|
): QueryServiceProp<ATTRIBUTES, DATA, Get<DATA, DATA_PATH>, CALL_ATTRIBUTES> => {
|
|
85
86
|
const {
|
|
86
87
|
dataPath,
|
|
87
|
-
options:
|
|
88
|
+
options: _queryOptions,
|
|
88
89
|
} = options
|
|
90
|
+
|
|
91
|
+
const observable = useContext(ObservableContext)
|
|
92
|
+
const isSkipped = ((_queryOptions?.skip) ?? false) || !observable
|
|
93
|
+
const queryOptions = useMemoObject({
|
|
94
|
+
..._queryOptions,
|
|
95
|
+
skip: isSkipped,
|
|
96
|
+
})
|
|
89
97
|
const query: QueryResult<DATA, ATTRIBUTES> = useQuery<DATA, ATTRIBUTES>(queryDocument, queryOptions)
|
|
90
98
|
const shownExceptionListRef = useRef<(ServiceErrorException)[]>([])
|
|
91
99
|
const {
|
|
@@ -95,6 +103,11 @@ export const useServiceQuery = <
|
|
|
95
103
|
const [fetchMoreFetching, setFetchMoreFetching] = useState(false)
|
|
96
104
|
const memoizedVariables = useMemoObject(queryOptions?.variables)
|
|
97
105
|
const memoizedQuery = useMemoObject<Typify<QueryResult<DATA, ATTRIBUTES>>>(query)
|
|
106
|
+
const recentData = useRef(memoizedQuery.data)
|
|
107
|
+
if (!isSkipped) {
|
|
108
|
+
recentData.current = memoizedQuery.data
|
|
109
|
+
}
|
|
110
|
+
const data: DATA | null = recentData.current ?? null
|
|
98
111
|
const context = useMemo(() => (
|
|
99
112
|
calculateContext(queryDocument, memoizedVariables)
|
|
100
113
|
), [queryDocument, memoizedVariables])
|
|
@@ -156,11 +169,12 @@ export const useServiceQuery = <
|
|
|
156
169
|
|
|
157
170
|
return useMemo(() => ({
|
|
158
171
|
query: memoizedQuery,
|
|
159
|
-
|
|
172
|
+
// eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
173
|
+
data: get(data, dataPath) as Get<DATA, DATA_PATH> | null,
|
|
160
174
|
fetching: memoizedQuery.loading,
|
|
161
175
|
fetchMoreFetching,
|
|
162
176
|
promiselessRefetch,
|
|
163
177
|
fetchMore,
|
|
164
178
|
exception,
|
|
165
|
-
}), [memoizedQuery, dataPath, fetchMoreFetching, promiselessRefetch, fetchMore, exception])
|
|
179
|
+
}), [memoizedQuery, data, dataPath, fetchMoreFetching, promiselessRefetch, fetchMore, exception])
|
|
166
180
|
}
|