skillbox/client/src/setup/apollo.ts

22 lines
549 B
TypeScript

import apolloClientFactory from '@/graphql/client';
import { useRouter } from 'vue-router';
const router = useRouter();
function networkErrorCallback(statusCode: number) {
if (statusCode === 402) {
router.push({ name: 'licenseActivation' });
}
}
const createApolloClients = () => {
return {
publicApolloClient: apolloClientFactory('/api/graphql-public/', null),
privateApolloClient: apolloClientFactory('/api/graphql/', networkErrorCallback),
};
};
const apolloClients = createApolloClients();
export default apolloClients;