@trackunit/react-core-contexts 1.3.35 → 1.3.37

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.
Files changed (3) hide show
  1. package/index.cjs.js +14 -12
  2. package/index.esm.js +14 -12
  3. package/package.json +7 -7
package/index.cjs.js CHANGED
@@ -72,19 +72,19 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
72
72
  headers: newHeaders,
73
73
  };
74
74
  });
75
- const errorLink = error.onError((errorResponse) => {
75
+ const errorLink = error.onError(({ graphQLErrors, networkError, operation, forward }) => {
76
76
  const traceIds = []; // Used to hold id's for use in Sentry
77
- if (errorResponse.graphQLErrors) {
78
- const code = errorResponse.graphQLErrors[0]?.extensions?.code;
77
+ if (graphQLErrors) {
78
+ const code = graphQLErrors[0]?.extensions?.code;
79
79
  if (code === "FORCE_RELOAD_BROWSER") {
80
80
  window.location.reload();
81
81
  }
82
82
  // eslint-disable-next-line no-console
83
- console.error(`Error calling: '${errorResponse.operation.getContext().clientAwareness.name}' fetching Data for: ${errorResponse.operation.operationName}`, errorResponse.graphQLErrors);
84
- errorResponse.graphQLErrors.forEach(error => {
83
+ console.error(`Error calling: '${operation.getContext().clientAwareness.name}' fetching Data for: ${operation.operationName}`, graphQLErrors);
84
+ graphQLErrors.forEach(error => {
85
85
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
86
86
  if ("extensions" in error && error.extensions) {
87
- error.extensions.traceId = errorResponse.response?.extensions?.traceId;
87
+ error.extensions.traceId = operation.getContext().response?.extensions?.traceId;
88
88
  // eslint-disable-next-line local-rules/no-typescript-assertion
89
89
  const traceId = error.extensions.traceId;
90
90
  traceIds.push(traceId);
@@ -103,10 +103,10 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
103
103
  message: "GraphQL Error",
104
104
  level: "error",
105
105
  data: {
106
- log: JSON.stringify(errorResponse.graphQLErrors),
106
+ log: JSON.stringify(graphQLErrors),
107
107
  },
108
108
  });
109
- const invalidToken = errorResponse.graphQLErrors.some(x => {
109
+ const invalidToken = graphQLErrors.some(x => {
110
110
  return (
111
111
  // saw it not unnecessary
112
112
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -120,7 +120,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
120
120
  info: "GraphQL Error - invalidToken",
121
121
  level: "warning",
122
122
  data: {
123
- log: JSON.stringify(errorResponse.graphQLErrors),
123
+ log: JSON.stringify(graphQLErrors),
124
124
  },
125
125
  })), {
126
126
  level: "warning",
@@ -128,14 +128,16 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
128
128
  });
129
129
  }
130
130
  }
131
- if (errorResponse.networkError) {
131
+ if (networkError) {
132
132
  // We skip the error logging if the error is an AbortError
133
- if (errorResponse.networkError.name === "AbortError") {
133
+ if (networkError.name === "AbortError") {
134
134
  return;
135
135
  }
136
136
  // eslint-disable-next-line no-console
137
- console.error(errorResponse.networkError);
137
+ console.error(networkError);
138
138
  }
139
+ // Forward the operation to the next link in the chain
140
+ return forward(operation);
139
141
  });
140
142
  const defaultOptions = {
141
143
  watchQuery: {
package/index.esm.js CHANGED
@@ -52,19 +52,19 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
52
52
  headers: newHeaders,
53
53
  };
54
54
  });
55
- const errorLink = onError((errorResponse) => {
55
+ const errorLink = onError(({ graphQLErrors, networkError, operation, forward }) => {
56
56
  const traceIds = []; // Used to hold id's for use in Sentry
57
- if (errorResponse.graphQLErrors) {
58
- const code = errorResponse.graphQLErrors[0]?.extensions?.code;
57
+ if (graphQLErrors) {
58
+ const code = graphQLErrors[0]?.extensions?.code;
59
59
  if (code === "FORCE_RELOAD_BROWSER") {
60
60
  window.location.reload();
61
61
  }
62
62
  // eslint-disable-next-line no-console
63
- console.error(`Error calling: '${errorResponse.operation.getContext().clientAwareness.name}' fetching Data for: ${errorResponse.operation.operationName}`, errorResponse.graphQLErrors);
64
- errorResponse.graphQLErrors.forEach(error => {
63
+ console.error(`Error calling: '${operation.getContext().clientAwareness.name}' fetching Data for: ${operation.operationName}`, graphQLErrors);
64
+ graphQLErrors.forEach(error => {
65
65
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
66
66
  if ("extensions" in error && error.extensions) {
67
- error.extensions.traceId = errorResponse.response?.extensions?.traceId;
67
+ error.extensions.traceId = operation.getContext().response?.extensions?.traceId;
68
68
  // eslint-disable-next-line local-rules/no-typescript-assertion
69
69
  const traceId = error.extensions.traceId;
70
70
  traceIds.push(traceId);
@@ -83,10 +83,10 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
83
83
  message: "GraphQL Error",
84
84
  level: "error",
85
85
  data: {
86
- log: JSON.stringify(errorResponse.graphQLErrors),
86
+ log: JSON.stringify(graphQLErrors),
87
87
  },
88
88
  });
89
- const invalidToken = errorResponse.graphQLErrors.some(x => {
89
+ const invalidToken = graphQLErrors.some(x => {
90
90
  return (
91
91
  // saw it not unnecessary
92
92
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
@@ -100,7 +100,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
100
100
  info: "GraphQL Error - invalidToken",
101
101
  level: "warning",
102
102
  data: {
103
- log: JSON.stringify(errorResponse.graphQLErrors),
103
+ log: JSON.stringify(graphQLErrors),
104
104
  },
105
105
  })), {
106
106
  level: "warning",
@@ -108,14 +108,16 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlIntern
108
108
  });
109
109
  }
110
110
  }
111
- if (errorResponse.networkError) {
111
+ if (networkError) {
112
112
  // We skip the error logging if the error is an AbortError
113
- if (errorResponse.networkError.name === "AbortError") {
113
+ if (networkError.name === "AbortError") {
114
114
  return;
115
115
  }
116
116
  // eslint-disable-next-line no-console
117
- console.error(errorResponse.networkError);
117
+ console.error(networkError);
118
118
  }
119
+ // Forward the operation to the next link in the chain
120
+ return forward(operation);
119
121
  });
120
122
  const defaultOptions = {
121
123
  watchQuery: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "1.3.35",
3
+ "version": "1.3.37",
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.32",
15
- "@trackunit/react-core-contexts-api": "1.4.33",
16
- "@trackunit/react-core-hooks": "1.3.33",
17
- "@trackunit/i18n-library-translation": "1.3.33",
18
- "@trackunit/react-components": "1.4.33",
19
- "@trackunit/iris-app-runtime-core": "1.4.33"
14
+ "@trackunit/iris-app-api": "1.3.33",
15
+ "@trackunit/react-core-contexts-api": "1.4.34",
16
+ "@trackunit/react-core-hooks": "1.3.34",
17
+ "@trackunit/i18n-library-translation": "1.3.34",
18
+ "@trackunit/react-components": "1.4.35",
19
+ "@trackunit/iris-app-runtime-core": "1.4.34"
20
20
  },
21
21
  "module": "./index.esm.js",
22
22
  "main": "./index.cjs.js",