37 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import getUrls from '@/config/urls';
import { ApolloLink, HttpLink, InMemoryCache } from '@apollo/client';
const { URL_CRM_GRAPHQL } = getUrls();
export const cache = new InMemoryCache();
const modifyDataLink = new ApolloLink((operation, forward) => {
const context = operation?.getContext();
return forward(operation).map((response) => {
if (!context?.disableModify) {
if (Object.keys(response?.data).includes('evo_addproduct_types')) {
response.data.evo_addproduct_types = response.data.evo_addproduct_types.map((x) => ({
...x,
label: `${x.label} (${x.evo_graph_price} руб.)`,
}));
}
if (Object.keys(response?.data).includes('evo_equipments')) {
response.data.evo_equipments = response.data.evo_equipments.map((x) => ({
...x,
label: `${x.label} (${x.evo_start_production_year})`,
}));
}
}
return response;
});
});
const httpLink = new HttpLink({
uri: URL_CRM_GRAPHQL,
});
export const link = modifyDataLink.concat(httpLink);