@trackunit/react-core-contexts 1.14.10-alpha-e76d0654d61.0 → 1.15.0
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 +61 -48
- package/index.esm.js +61 -48
- package/package.json +9 -9
package/index.cjs.js
CHANGED
|
@@ -30,60 +30,73 @@ const createErrorLink = ({ errorHandler, token, }) => {
|
|
|
30
30
|
// eslint-disable-next-line no-console
|
|
31
31
|
console.error(networkError);
|
|
32
32
|
}
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
// Fallback to response.extensions.traceId if no traceIds found in errors
|
|
44
|
-
const traceId = response.extensions?.traceId;
|
|
45
|
-
if (traceIds.length === 0 && typeof traceId === "string") {
|
|
46
|
-
traceIds.push(traceId);
|
|
47
|
-
}
|
|
48
|
-
const code = graphQLErrors[0]?.extensions?.code;
|
|
49
|
-
if (code === "FORCE_RELOAD_BROWSER") {
|
|
50
|
-
window.location.reload();
|
|
33
|
+
// Determine if this is a mutation - mutations should NOT be retried as they have side effects
|
|
34
|
+
const definition = utilities.getMainDefinition(operation.query);
|
|
35
|
+
const isMutation = definition.kind === "OperationDefinition" && definition.operation === "mutation";
|
|
36
|
+
if (graphQLErrors) {
|
|
37
|
+
// Collect traceIds from graphQLErrors
|
|
38
|
+
const traceIds = [];
|
|
39
|
+
graphQLErrors.forEach(error => {
|
|
40
|
+
if ("extensions" in error && error.extensions && typeof error.extensions.traceId === "string") {
|
|
41
|
+
traceIds.push(error.extensions.traceId);
|
|
51
42
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
43
|
+
});
|
|
44
|
+
const code = graphQLErrors[0]?.extensions?.code;
|
|
45
|
+
if (code === "FORCE_RELOAD_BROWSER") {
|
|
46
|
+
window.location.reload();
|
|
47
|
+
}
|
|
48
|
+
// eslint-disable-next-line no-console
|
|
49
|
+
console.error(`Error calling: '${operation.getContext().clientAwareness.name}' fetching Data for: ${operation.operationName}`, graphQLErrors);
|
|
50
|
+
/**
|
|
51
|
+
* We want to see the full graphQL error since
|
|
52
|
+
* it contains extra details like the query/mutation
|
|
53
|
+
* name.
|
|
54
|
+
*/
|
|
55
|
+
if (traceIds.length) {
|
|
56
|
+
errorHandler.setTag("traceIds", traceIds.join(", "));
|
|
57
|
+
}
|
|
58
|
+
errorHandler.addBreadcrumb({
|
|
59
|
+
category: "GraphQL",
|
|
60
|
+
message: "GraphQL Error",
|
|
61
|
+
level: "error",
|
|
62
|
+
data: {
|
|
63
|
+
log: JSON.stringify(graphQLErrors),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
const invalidToken = graphQLErrors.some(x => {
|
|
67
|
+
return (x.extensions?.code === "UNAUTHENTICATED" ||
|
|
68
|
+
x.message.includes("Invalid token specified") ||
|
|
69
|
+
x.message.includes("Access denied! You need to be authorized to perform this action!"));
|
|
70
|
+
});
|
|
71
|
+
if (invalidToken && token) {
|
|
72
|
+
errorHandler.captureException(new Error(JSON.stringify({
|
|
63
73
|
category: "GraphQL",
|
|
64
|
-
|
|
65
|
-
level: "
|
|
74
|
+
info: "GraphQL Error - invalidToken",
|
|
75
|
+
level: "warning",
|
|
66
76
|
data: {
|
|
67
77
|
log: JSON.stringify(graphQLErrors),
|
|
68
78
|
},
|
|
79
|
+
})), {
|
|
80
|
+
level: "warning",
|
|
81
|
+
fingerprint: ["GraphQL Error - invalidToken"],
|
|
69
82
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Only retry queries, never mutations (mutations have side effects and should not be auto-retried)
|
|
86
|
+
if (isMutation) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// For queries, forward to allow retry and capture response extensions
|
|
90
|
+
return forward(operation).map(response => {
|
|
91
|
+
// Capture traceId from response extensions if not already found in errors
|
|
92
|
+
if (graphQLErrors) {
|
|
93
|
+
const traceId = response.extensions?.traceId;
|
|
94
|
+
if (typeof traceId === "string") {
|
|
95
|
+
// Check if we already have traceIds from the errors
|
|
96
|
+
const hasTraceIdsFromErrors = graphQLErrors.some(error => "extensions" in error && error.extensions && typeof error.extensions.traceId === "string");
|
|
97
|
+
if (!hasTraceIdsFromErrors) {
|
|
98
|
+
errorHandler.setTag("traceIds", traceId);
|
|
99
|
+
}
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
102
|
return response;
|
package/index.esm.js
CHANGED
|
@@ -28,60 +28,73 @@ const createErrorLink = ({ errorHandler, token, }) => {
|
|
|
28
28
|
// eslint-disable-next-line no-console
|
|
29
29
|
console.error(networkError);
|
|
30
30
|
}
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
// Fallback to response.extensions.traceId if no traceIds found in errors
|
|
42
|
-
const traceId = response.extensions?.traceId;
|
|
43
|
-
if (traceIds.length === 0 && typeof traceId === "string") {
|
|
44
|
-
traceIds.push(traceId);
|
|
45
|
-
}
|
|
46
|
-
const code = graphQLErrors[0]?.extensions?.code;
|
|
47
|
-
if (code === "FORCE_RELOAD_BROWSER") {
|
|
48
|
-
window.location.reload();
|
|
31
|
+
// Determine if this is a mutation - mutations should NOT be retried as they have side effects
|
|
32
|
+
const definition = getMainDefinition(operation.query);
|
|
33
|
+
const isMutation = definition.kind === "OperationDefinition" && definition.operation === "mutation";
|
|
34
|
+
if (graphQLErrors) {
|
|
35
|
+
// Collect traceIds from graphQLErrors
|
|
36
|
+
const traceIds = [];
|
|
37
|
+
graphQLErrors.forEach(error => {
|
|
38
|
+
if ("extensions" in error && error.extensions && typeof error.extensions.traceId === "string") {
|
|
39
|
+
traceIds.push(error.extensions.traceId);
|
|
49
40
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
41
|
+
});
|
|
42
|
+
const code = graphQLErrors[0]?.extensions?.code;
|
|
43
|
+
if (code === "FORCE_RELOAD_BROWSER") {
|
|
44
|
+
window.location.reload();
|
|
45
|
+
}
|
|
46
|
+
// eslint-disable-next-line no-console
|
|
47
|
+
console.error(`Error calling: '${operation.getContext().clientAwareness.name}' fetching Data for: ${operation.operationName}`, graphQLErrors);
|
|
48
|
+
/**
|
|
49
|
+
* We want to see the full graphQL error since
|
|
50
|
+
* it contains extra details like the query/mutation
|
|
51
|
+
* name.
|
|
52
|
+
*/
|
|
53
|
+
if (traceIds.length) {
|
|
54
|
+
errorHandler.setTag("traceIds", traceIds.join(", "));
|
|
55
|
+
}
|
|
56
|
+
errorHandler.addBreadcrumb({
|
|
57
|
+
category: "GraphQL",
|
|
58
|
+
message: "GraphQL Error",
|
|
59
|
+
level: "error",
|
|
60
|
+
data: {
|
|
61
|
+
log: JSON.stringify(graphQLErrors),
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const invalidToken = graphQLErrors.some(x => {
|
|
65
|
+
return (x.extensions?.code === "UNAUTHENTICATED" ||
|
|
66
|
+
x.message.includes("Invalid token specified") ||
|
|
67
|
+
x.message.includes("Access denied! You need to be authorized to perform this action!"));
|
|
68
|
+
});
|
|
69
|
+
if (invalidToken && token) {
|
|
70
|
+
errorHandler.captureException(new Error(JSON.stringify({
|
|
61
71
|
category: "GraphQL",
|
|
62
|
-
|
|
63
|
-
level: "
|
|
72
|
+
info: "GraphQL Error - invalidToken",
|
|
73
|
+
level: "warning",
|
|
64
74
|
data: {
|
|
65
75
|
log: JSON.stringify(graphQLErrors),
|
|
66
76
|
},
|
|
77
|
+
})), {
|
|
78
|
+
level: "warning",
|
|
79
|
+
fingerprint: ["GraphQL Error - invalidToken"],
|
|
67
80
|
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Only retry queries, never mutations (mutations have side effects and should not be auto-retried)
|
|
84
|
+
if (isMutation) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// For queries, forward to allow retry and capture response extensions
|
|
88
|
+
return forward(operation).map(response => {
|
|
89
|
+
// Capture traceId from response extensions if not already found in errors
|
|
90
|
+
if (graphQLErrors) {
|
|
91
|
+
const traceId = response.extensions?.traceId;
|
|
92
|
+
if (typeof traceId === "string") {
|
|
93
|
+
// Check if we already have traceIds from the errors
|
|
94
|
+
const hasTraceIdsFromErrors = graphQLErrors.some(error => "extensions" in error && error.extensions && typeof error.extensions.traceId === "string");
|
|
95
|
+
if (!hasTraceIdsFromErrors) {
|
|
96
|
+
errorHandler.setTag("traceIds", traceId);
|
|
97
|
+
}
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
100
|
return response;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -9,16 +9,16 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@apollo/client": "3.13.8",
|
|
11
11
|
"react": "19.0.0",
|
|
12
|
-
"@trackunit/iris-app-api": "1.14.
|
|
13
|
-
"@trackunit/iris-app-runtime-core-api": "1.11.
|
|
14
|
-
"@trackunit/react-core-hooks": "1.11.
|
|
15
|
-
"@trackunit/i18n-library-translation": "1.11.
|
|
16
|
-
"@trackunit/react-components": "1.15.
|
|
17
|
-
"@trackunit/iris-app-runtime-core": "1.12.
|
|
18
|
-
"graphql": "16.
|
|
12
|
+
"@trackunit/iris-app-api": "1.14.8",
|
|
13
|
+
"@trackunit/iris-app-runtime-core-api": "1.11.8",
|
|
14
|
+
"@trackunit/react-core-hooks": "1.11.8",
|
|
15
|
+
"@trackunit/i18n-library-translation": "1.11.8",
|
|
16
|
+
"@trackunit/react-components": "1.15.9",
|
|
17
|
+
"@trackunit/iris-app-runtime-core": "1.12.8",
|
|
18
|
+
"graphql": "^16.10.0",
|
|
19
19
|
"graphql-sse": "^2.5.4",
|
|
20
20
|
"@js-temporal/polyfill": "^0.5.1",
|
|
21
|
-
"@trackunit/react-core-contexts-api": "1.12.
|
|
21
|
+
"@trackunit/react-core-contexts-api": "1.12.8"
|
|
22
22
|
},
|
|
23
23
|
"module": "./index.esm.js",
|
|
24
24
|
"main": "./index.cjs.js",
|