@trackunit/react-core-contexts 0.4.537 → 0.4.538
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 +4 -1
- package/index.esm.js +4 -1
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
6
6
|
var client = require('@apollo/client');
|
|
7
7
|
var context = require('@apollo/client/link/context');
|
|
8
8
|
var error = require('@apollo/client/link/error');
|
|
9
|
+
var removeTypename = require('@apollo/client/link/remove-typename');
|
|
9
10
|
var reactCoreHooks = require('@trackunit/react-core-hooks');
|
|
10
11
|
var apolloUploadClient = require('apollo-upload-client');
|
|
11
12
|
var React = require('react');
|
|
@@ -175,6 +176,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
|
|
|
175
176
|
fetchPolicy: "no-cache",
|
|
176
177
|
},
|
|
177
178
|
};
|
|
179
|
+
const removeTypenameLink = removeTypename.removeTypenameFromVariables();
|
|
178
180
|
return {
|
|
179
181
|
client: new client.ApolloClient({
|
|
180
182
|
name: "Manager",
|
|
@@ -184,6 +186,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
|
|
|
184
186
|
link: client.from([
|
|
185
187
|
errorLink,
|
|
186
188
|
authLink,
|
|
189
|
+
removeTypenameLink,
|
|
187
190
|
client.split(operation => operation.getContext().clientName === "imageupload", imageUploadGraphQLLink),
|
|
188
191
|
client.split(operation => operation.getContext().clientName === "manager", managerGraphQLLink, client.split(operation => operation.getContext().clientName === "report", reportGraphQLLink, client.split(() => global.gql === "internal", internalGraphQLLink, publicGraphQLLink))),
|
|
189
192
|
]),
|
|
@@ -201,7 +204,7 @@ const useApolloClient = () => {
|
|
|
201
204
|
const { token } = reactCoreHooks.useToken();
|
|
202
205
|
const errorHandler = reactCoreHooks.useErrorHandler();
|
|
203
206
|
const clientRef = React.useRef(null);
|
|
204
|
-
/*
|
|
207
|
+
/* DON'T CHANGE THIS ! its there to ensure we don't recreate apollo client just because the token changes,
|
|
205
208
|
the token will then be set on the instance without react reporting a new client
|
|
206
209
|
and recreating if token change from null to something*/
|
|
207
210
|
if (!clientRef.current) {
|
package/index.esm.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { ApolloProvider, ApolloClient, InMemoryCache, from, split } from '@apollo/client';
|
|
3
3
|
import { setContext } from '@apollo/client/link/context';
|
|
4
4
|
import { onError } from '@apollo/client/link/error';
|
|
5
|
+
import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename';
|
|
5
6
|
import { useEnvironment, useToken, useErrorHandler, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider } from '@trackunit/react-core-hooks';
|
|
6
7
|
import { createUploadLink } from 'apollo-upload-client';
|
|
7
8
|
import * as React from 'react';
|
|
@@ -152,6 +153,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
|
|
|
152
153
|
fetchPolicy: "no-cache",
|
|
153
154
|
},
|
|
154
155
|
};
|
|
156
|
+
const removeTypenameLink = removeTypenameFromVariables();
|
|
155
157
|
return {
|
|
156
158
|
client: new ApolloClient({
|
|
157
159
|
name: "Manager",
|
|
@@ -161,6 +163,7 @@ const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlManage
|
|
|
161
163
|
link: from([
|
|
162
164
|
errorLink,
|
|
163
165
|
authLink,
|
|
166
|
+
removeTypenameLink,
|
|
164
167
|
split(operation => operation.getContext().clientName === "imageupload", imageUploadGraphQLLink),
|
|
165
168
|
split(operation => operation.getContext().clientName === "manager", managerGraphQLLink, split(operation => operation.getContext().clientName === "report", reportGraphQLLink, split(() => global.gql === "internal", internalGraphQLLink, publicGraphQLLink))),
|
|
166
169
|
]),
|
|
@@ -178,7 +181,7 @@ const useApolloClient = () => {
|
|
|
178
181
|
const { token } = useToken();
|
|
179
182
|
const errorHandler = useErrorHandler();
|
|
180
183
|
const clientRef = useRef(null);
|
|
181
|
-
/*
|
|
184
|
+
/* DON'T CHANGE THIS ! its there to ensure we don't recreate apollo client just because the token changes,
|
|
182
185
|
the token will then be set on the instance without react reporting a new client
|
|
183
186
|
and recreating if token change from null to something*/
|
|
184
187
|
if (!clientRef.current) {
|