@trackunit/react-core-contexts 1.3.187 → 1.3.189
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 +3 -7
- package/index.esm.js +3 -7
- package/package.json +8 -8
package/index.cjs.js
CHANGED
|
@@ -59,14 +59,11 @@ const generateHeaders = (token, tracingHeaders) => {
|
|
|
59
59
|
}
|
|
60
60
|
return headers;
|
|
61
61
|
};
|
|
62
|
-
const createApolloClient = ({
|
|
62
|
+
const createApolloClient = ({ graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, isDev, tracingHeaders, firstToken, errorHandler, }) => {
|
|
63
63
|
let token;
|
|
64
64
|
if (!token) {
|
|
65
65
|
token = firstToken;
|
|
66
66
|
}
|
|
67
|
-
const managerGraphQLLink = client.createHttpLink({
|
|
68
|
-
uri: request => graphqlManagerUrl + "/" + request.operationName,
|
|
69
|
-
});
|
|
70
67
|
const publicGraphQLLink = client.createHttpLink({
|
|
71
68
|
uri: request => graphqlPublicUrl + "/" + request.operationName,
|
|
72
69
|
});
|
|
@@ -192,7 +189,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
192
189
|
}, sseLink, client.from([
|
|
193
190
|
errorLink,
|
|
194
191
|
removeTypenameLink,
|
|
195
|
-
client.split(operation => operation.getContext().clientName === "
|
|
192
|
+
client.split(operation => operation.getContext().clientName === "report", reportGraphQLLink, client.split(() => global.gql === "internal", internalGraphQLLink, publicGraphQLLink)),
|
|
196
193
|
])),
|
|
197
194
|
]);
|
|
198
195
|
return {
|
|
@@ -220,7 +217,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
220
217
|
};
|
|
221
218
|
};
|
|
222
219
|
const useApolloClient = () => {
|
|
223
|
-
const {
|
|
220
|
+
const { graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, environment, tracingHeaders } = reactCoreHooks.useEnvironment();
|
|
224
221
|
const { token: currentToken } = reactCoreHooks.useToken();
|
|
225
222
|
const errorHandler = reactCoreHooks.useErrorHandler();
|
|
226
223
|
const [client] = React.useState(() => {
|
|
@@ -228,7 +225,6 @@ const useApolloClient = () => {
|
|
|
228
225
|
/* DON'T CHANGE THIS ! its there to ensure we don't recreate apollo client just because the token changes,
|
|
229
226
|
the token will then be set on the instance without react reporting a new client
|
|
230
227
|
and recreating if token change from null to something*/
|
|
231
|
-
graphqlManagerUrl,
|
|
232
228
|
graphqlPublicUrl,
|
|
233
229
|
graphqlInternalUrl,
|
|
234
230
|
graphqlReportUrl,
|
package/index.esm.js
CHANGED
|
@@ -39,14 +39,11 @@ const generateHeaders = (token, tracingHeaders) => {
|
|
|
39
39
|
}
|
|
40
40
|
return headers;
|
|
41
41
|
};
|
|
42
|
-
const createApolloClient = ({
|
|
42
|
+
const createApolloClient = ({ graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, isDev, tracingHeaders, firstToken, errorHandler, }) => {
|
|
43
43
|
let token;
|
|
44
44
|
if (!token) {
|
|
45
45
|
token = firstToken;
|
|
46
46
|
}
|
|
47
|
-
const managerGraphQLLink = createHttpLink({
|
|
48
|
-
uri: request => graphqlManagerUrl + "/" + request.operationName,
|
|
49
|
-
});
|
|
50
47
|
const publicGraphQLLink = createHttpLink({
|
|
51
48
|
uri: request => graphqlPublicUrl + "/" + request.operationName,
|
|
52
49
|
});
|
|
@@ -172,7 +169,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
172
169
|
}, sseLink, from([
|
|
173
170
|
errorLink,
|
|
174
171
|
removeTypenameLink,
|
|
175
|
-
split(operation => operation.getContext().clientName === "
|
|
172
|
+
split(operation => operation.getContext().clientName === "report", reportGraphQLLink, split(() => global.gql === "internal", internalGraphQLLink, publicGraphQLLink)),
|
|
176
173
|
])),
|
|
177
174
|
]);
|
|
178
175
|
return {
|
|
@@ -200,7 +197,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
|
|
|
200
197
|
};
|
|
201
198
|
};
|
|
202
199
|
const useApolloClient = () => {
|
|
203
|
-
const {
|
|
200
|
+
const { graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, environment, tracingHeaders } = useEnvironment();
|
|
204
201
|
const { token: currentToken } = useToken();
|
|
205
202
|
const errorHandler = useErrorHandler();
|
|
206
203
|
const [client] = useState(() => {
|
|
@@ -208,7 +205,6 @@ const useApolloClient = () => {
|
|
|
208
205
|
/* DON'T CHANGE THIS ! its there to ensure we don't recreate apollo client just because the token changes,
|
|
209
206
|
the token will then be set on the instance without react reporting a new client
|
|
210
207
|
and recreating if token change from null to something*/
|
|
211
|
-
graphqlManagerUrl,
|
|
212
208
|
graphqlPublicUrl,
|
|
213
209
|
graphqlInternalUrl,
|
|
214
210
|
graphqlReportUrl,
|
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.189",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -11,15 +11,15 @@
|
|
|
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.142",
|
|
15
|
+
"@trackunit/react-core-contexts-api": "1.4.140",
|
|
16
|
+
"@trackunit/react-core-hooks": "1.3.145",
|
|
17
|
+
"@trackunit/i18n-library-translation": "1.3.152",
|
|
18
|
+
"@trackunit/react-components": "1.4.164",
|
|
19
|
+
"@trackunit/iris-app-runtime-core": "1.4.143",
|
|
20
20
|
"graphql": "^16.10.0",
|
|
21
21
|
"graphql-sse": "^2.5.4",
|
|
22
|
-
"@trackunit/react-test-setup": "1.0.
|
|
22
|
+
"@trackunit/react-test-setup": "1.0.23"
|
|
23
23
|
},
|
|
24
24
|
"module": "./index.esm.js",
|
|
25
25
|
"main": "./index.cjs.js",
|