showing results for - "error network error 3a forward is not a function in apollo header authorixation"
Natalia
21 Jun 2020
1import { ApolloClient } from 'apollo-client'
2import { HttpLink } from 'apollo-link-http'
3import { setContext } from 'apollo-link-context'
4import { onError } from 'apollo-link-error'
5import { InMemoryCache } from 'apollo-cache-inmemory'
6
7const httpLink = new HttpLink({
8  uri: // my api URI
9})
10
11const authLink = setContext((_, { headers }) => {
12  // my authorization stuff
13})
14
15const errorLink = onError(({ graphQLErrors, networkError }) => {
16  // my error handling logic
17})
18
19const apolloClient = new ApolloClient({
20  link: authLink.concat(errorLink, httpLink),
21  cache: new InMemoryCache()
22})