MK
Size: a a a
MK
M
MK
VK
MK
Б
MK
VK
MK
MK
MK
VK
MK
MK
AS
AS
import { ApolloClient, ApolloLink, HttpLink, InMemoryCache } from '@apollo/client';вот код конфига
import { message } from 'antd';
import { onError } from "@apollo/client/link/error";
const URL = 'https://app.china-parts.ru/graphql/'
const configureApolloo = () => {
const errorLink = onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.map(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
)
);
if (networkError) console.log(`[Network error]: ${networkError}`);
});
const httpLink = new HttpLink({
uri: URL,
});
const cache = new InMemoryCache();
const link = ApolloLink.from([
httpLink,
errorLink,
])
const client = new ApolloClient({
link: link,
uri: URL,
headers: {
// Authorization: `Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MTE4MjYxMDUsImV4cCI6MTY0MzM2MjEwNSwidXNlcl9pZCI6MSwiZGV2aWNlX2lkIjoxfQ.nx996TVwtyi5PCPBxLKXXyyc1eDcXc4ud8SqcZFWgI0`,
'Cache-Control': 'no-cache',
},
cache,
});
return client;
};
export default configureApolloo;
Б
function smoothLazyLoad(path){
return React.lazy(async () => {
await sleep(300);
return import(path)
})
}
Sleep
- пустой промисс с таймаутом. Стандартная практикаn
DP
swagger-ui-express
и формат yaml
)DK