| 241 | } |
| 242 | |
| 243 | getApolloClient() { |
| 244 | const authLink = setContext((_, { headers }) => { |
| 245 | return { |
| 246 | headers: { |
| 247 | 'Content-Type': 'application/json; charset=utf-8', |
| 248 | ...headers, |
| 249 | authorization: this.token ? `Bearer ${this.token}` : '', |
| 250 | }, |
| 251 | }; |
| 252 | }); |
| 253 | const httpLink = createHttpLink({ uri: this.graphQLAPIRoot }); |
| 254 | return new ApolloClient({ |
| 255 | link: authLink.concat(httpLink), |
| 256 | cache: new InMemoryCache(), |
| 257 | defaultOptions: { |
| 258 | watchQuery: { |
| 259 | fetchPolicy: NO_CACHE, |
| 260 | errorPolicy: 'ignore', |
| 261 | }, |
| 262 | query: { |
| 263 | fetchPolicy: NO_CACHE, |
| 264 | errorPolicy: 'all', |
| 265 | }, |
| 266 | }, |
| 267 | }); |
| 268 | } |
| 269 | |
| 270 | reset() { |
| 271 | return this.graphQLClient?.resetStore(); |