@stolostron/multicluster-sdk
Version:
Provides extensions and APIs that dynamic plugins can use to leverage multicluster capabilities provided by Red Hat Advanced Cluster Management.
42 lines • 1.38 kB
JavaScript
;
/* Copyright Contributors to the Open Cluster Management project */
Object.defineProperty(exports, "__esModule", { value: true });
exports.searchClient = void 0;
const client_1 = require("@apollo/client");
const searchUtils_1 = require("./searchUtils");
const constants_1 = require("../constants");
const csrfHeaderLink = new client_1.ApolloLink((operation, forward) => {
const csrfToken = (0, searchUtils_1.getCookie)('csrf-token');
if (csrfToken) {
operation.setContext(({ headers = {} }) => ({
headers: {
...headers,
'X-CSRFToken': csrfToken,
},
}));
}
return forward(operation);
});
const httpLink = new client_1.HttpLink({
uri: () => `${constants_1.BACKEND_URL}/proxy/search`,
});
exports.searchClient = new client_1.ApolloClient({
connectToDevTools: process.env.NODE_ENV === 'development',
link: (0, client_1.from)([csrfHeaderLink, httpLink]),
cache: new client_1.InMemoryCache(),
credentials: 'same-origin',
defaultOptions: {
watchQuery: {
fetchPolicy: 'network-only',
errorPolicy: 'all',
},
query: {
fetchPolicy: 'network-only',
errorPolicy: 'all',
},
mutate: {
errorPolicy: 'all',
},
},
});
//# sourceMappingURL=search-client.js.map