@trackunit/react-core-contexts 1.3.59 → 1.3.63
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/index.cjs.js +12 -15
- package/index.esm.js +13 -16
- package/package.json +7 -7
package/index.cjs.js
CHANGED
|
@@ -82,8 +82,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
82
82
|
// eslint-disable-next-line no-console
|
|
83
83
|
console.error(`Error calling: '${operation.getContext().clientAwareness.name}' fetching Data for: ${operation.operationName}`, graphQLErrors);
|
|
84
84
|
graphQLErrors.forEach(error => {
|
|
85
|
-
|
|
86
|
-
if ("extensions" in error && error.extensions) {
|
|
85
|
+
if ("extensions" in error) {
|
|
87
86
|
error.extensions.traceId = operation.getContext().response?.extensions?.traceId;
|
|
88
87
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
89
88
|
const traceId = error.extensions.traceId;
|
|
@@ -109,8 +108,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
109
108
|
const invalidToken = graphQLErrors.some(x => {
|
|
110
109
|
return (
|
|
111
110
|
// saw it not unnecessary
|
|
112
|
-
|
|
113
|
-
(x.extensions && x.extensions.code === "UNAUTHENTICATED") ||
|
|
111
|
+
x.extensions.code === "UNAUTHENTICATED" ||
|
|
114
112
|
x.message.includes("Invalid token specified") ||
|
|
115
113
|
x.message.includes("Access denied! You need to be authorized to perform this action!"));
|
|
116
114
|
});
|
|
@@ -187,12 +185,11 @@ const useApolloClient = () => {
|
|
|
187
185
|
const { graphqlManagerUrl, graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, environment, tracingHeaders } = reactCoreHooks.useEnvironment();
|
|
188
186
|
const { token } = reactCoreHooks.useToken();
|
|
189
187
|
const errorHandler = reactCoreHooks.useErrorHandler();
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
clientRef.current = createApolloClient({
|
|
188
|
+
const [client] = React.useState(() => {
|
|
189
|
+
return createApolloClient({
|
|
190
|
+
/* DON'T CHANGE THIS ! its there to ensure we don't recreate apollo client just because the token changes,
|
|
191
|
+
the token will then be set on the instance without react reporting a new client
|
|
192
|
+
and recreating if token change from null to something*/
|
|
196
193
|
graphqlManagerUrl,
|
|
197
194
|
graphqlPublicUrl,
|
|
198
195
|
graphqlInternalUrl,
|
|
@@ -202,11 +199,11 @@ const useApolloClient = () => {
|
|
|
202
199
|
firstToken: token,
|
|
203
200
|
errorHandler,
|
|
204
201
|
});
|
|
202
|
+
});
|
|
203
|
+
if (client.getToken() !== token) {
|
|
204
|
+
client.setToken(token);
|
|
205
205
|
}
|
|
206
|
-
|
|
207
|
-
clientRef.current.setToken(token);
|
|
208
|
-
}
|
|
209
|
-
return clientRef.current.client;
|
|
206
|
+
return client;
|
|
210
207
|
};
|
|
211
208
|
/**
|
|
212
209
|
* This is a provider for the ManagerApolloContext.
|
|
@@ -216,7 +213,7 @@ const useApolloClient = () => {
|
|
|
216
213
|
* @returns {ReactElement} The provider.
|
|
217
214
|
*/
|
|
218
215
|
const ManagerApolloProvider = ({ children }) => {
|
|
219
|
-
const client$1 = useApolloClient();
|
|
216
|
+
const { client: client$1 } = useApolloClient();
|
|
220
217
|
return jsxRuntime.jsx(client.ApolloProvider, { client: client$1, children: children });
|
|
221
218
|
};
|
|
222
219
|
|
package/index.esm.js
CHANGED
|
@@ -5,7 +5,7 @@ import { onError } from '@apollo/client/link/error';
|
|
|
5
5
|
import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename';
|
|
6
6
|
import { useEnvironment, useToken, useErrorHandler, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider } from '@trackunit/react-core-hooks';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import {
|
|
8
|
+
import { useState, useMemo, useEffect } from 'react';
|
|
9
9
|
import '@js-temporal/polyfill';
|
|
10
10
|
import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
|
|
11
11
|
import { Spinner } from '@trackunit/react-components';
|
|
@@ -62,8 +62,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
62
62
|
// eslint-disable-next-line no-console
|
|
63
63
|
console.error(`Error calling: '${operation.getContext().clientAwareness.name}' fetching Data for: ${operation.operationName}`, graphQLErrors);
|
|
64
64
|
graphQLErrors.forEach(error => {
|
|
65
|
-
|
|
66
|
-
if ("extensions" in error && error.extensions) {
|
|
65
|
+
if ("extensions" in error) {
|
|
67
66
|
error.extensions.traceId = operation.getContext().response?.extensions?.traceId;
|
|
68
67
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
69
68
|
const traceId = error.extensions.traceId;
|
|
@@ -89,8 +88,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
89
88
|
const invalidToken = graphQLErrors.some(x => {
|
|
90
89
|
return (
|
|
91
90
|
// saw it not unnecessary
|
|
92
|
-
|
|
93
|
-
(x.extensions && x.extensions.code === "UNAUTHENTICATED") ||
|
|
91
|
+
x.extensions.code === "UNAUTHENTICATED" ||
|
|
94
92
|
x.message.includes("Invalid token specified") ||
|
|
95
93
|
x.message.includes("Access denied! You need to be authorized to perform this action!"));
|
|
96
94
|
});
|
|
@@ -167,12 +165,11 @@ const useApolloClient = () => {
|
|
|
167
165
|
const { graphqlManagerUrl, graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, environment, tracingHeaders } = useEnvironment();
|
|
168
166
|
const { token } = useToken();
|
|
169
167
|
const errorHandler = useErrorHandler();
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
clientRef.current = createApolloClient({
|
|
168
|
+
const [client] = useState(() => {
|
|
169
|
+
return createApolloClient({
|
|
170
|
+
/* DON'T CHANGE THIS ! its there to ensure we don't recreate apollo client just because the token changes,
|
|
171
|
+
the token will then be set on the instance without react reporting a new client
|
|
172
|
+
and recreating if token change from null to something*/
|
|
176
173
|
graphqlManagerUrl,
|
|
177
174
|
graphqlPublicUrl,
|
|
178
175
|
graphqlInternalUrl,
|
|
@@ -182,11 +179,11 @@ const useApolloClient = () => {
|
|
|
182
179
|
firstToken: token,
|
|
183
180
|
errorHandler,
|
|
184
181
|
});
|
|
182
|
+
});
|
|
183
|
+
if (client.getToken() !== token) {
|
|
184
|
+
client.setToken(token);
|
|
185
185
|
}
|
|
186
|
-
|
|
187
|
-
clientRef.current.setToken(token);
|
|
188
|
-
}
|
|
189
|
-
return clientRef.current.client;
|
|
186
|
+
return client;
|
|
190
187
|
};
|
|
191
188
|
/**
|
|
192
189
|
* This is a provider for the ManagerApolloContext.
|
|
@@ -196,7 +193,7 @@ const useApolloClient = () => {
|
|
|
196
193
|
* @returns {ReactElement} The provider.
|
|
197
194
|
*/
|
|
198
195
|
const ManagerApolloProvider = ({ children }) => {
|
|
199
|
-
const client = useApolloClient();
|
|
196
|
+
const { client } = useApolloClient();
|
|
200
197
|
return jsx(ApolloProvider, { client: client, children: children });
|
|
201
198
|
};
|
|
202
199
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.63",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"react": "19.0.0",
|
|
12
12
|
"@js-temporal/polyfill": "^0.4.4",
|
|
13
13
|
"jest-fetch-mock": "^3.0.3",
|
|
14
|
-
"@trackunit/iris-app-api": "1.3.
|
|
15
|
-
"@trackunit/react-core-contexts-api": "1.4.
|
|
16
|
-
"@trackunit/react-core-hooks": "1.3.
|
|
17
|
-
"@trackunit/i18n-library-translation": "1.3.
|
|
18
|
-
"@trackunit/react-components": "1.4.
|
|
19
|
-
"@trackunit/iris-app-runtime-core": "1.4.
|
|
14
|
+
"@trackunit/iris-app-api": "1.3.48",
|
|
15
|
+
"@trackunit/react-core-contexts-api": "1.4.47",
|
|
16
|
+
"@trackunit/react-core-hooks": "1.3.49",
|
|
17
|
+
"@trackunit/i18n-library-translation": "1.3.51",
|
|
18
|
+
"@trackunit/react-components": "1.4.56",
|
|
19
|
+
"@trackunit/iris-app-runtime-core": "1.4.48"
|
|
20
20
|
},
|
|
21
21
|
"module": "./index.esm.js",
|
|
22
22
|
"main": "./index.cjs.js",
|