Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | import { ApolloClient, createHttpLink, InMemoryCache } from '@apollo/client' import { BASE_URL } from '@/shared/config' import { setContext } from '@apollo/client/link/context' import { parseCookies } from 'nookies' const httpLink = createHttpLink({ uri: BASE_URL + '/graphql', }) const authLink = setContext((_, { headers }) => { const cookies = parseCookies() const access_token = cookies['access_token'] return { headers: { ...headers, authorization: access_token ? `Bearer ${access_token}` : '', }, } }) const clientGraphql = new ApolloClient({ link: authLink.concat(httpLink), cache: new InMemoryCache(), }) export default clientGraphql |