2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-12-18 14:43:23 +00:00
|
|
|
import { InMemoryCache } from 'apollo-cache-inmemory';
|
2019-09-09 11:33:39 +01:00
|
|
|
import ApolloClient from 'apollo-client/ApolloClient';
|
2018-12-18 14:43:23 +00:00
|
|
|
import { setContext } from 'apollo-link-context';
|
2019-09-09 11:33:39 +01:00
|
|
|
import { HttpLink } from 'apollo-link-http';
|
|
|
|
|
2018-11-27 13:14:10 +00:00
|
|
|
// Satellite url
|
2018-11-26 15:57:11 +00:00
|
|
|
const satelliteUrl = new HttpLink({
|
2019-08-20 14:31:01 +01:00
|
|
|
uri: process.env.VUE_APP_ENDPOINT_URL,
|
2018-11-26 15:57:11 +00:00
|
|
|
});
|
|
|
|
|
2020-01-20 18:57:14 +00:00
|
|
|
// Adding additional headers
|
2018-12-18 14:43:23 +00:00
|
|
|
const authLink = setContext((_, {headers}) => {
|
2019-07-22 10:46:26 +01:00
|
|
|
// return the headers to the context so httpLink can read them
|
2019-02-20 13:33:56 +00:00
|
|
|
return {
|
|
|
|
headers: {
|
|
|
|
...headers,
|
2019-09-13 15:58:18 +01:00
|
|
|
},
|
2019-02-20 13:33:56 +00:00
|
|
|
};
|
2018-11-27 13:14:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Creating apollo client
|
2019-10-28 13:27:12 +00:00
|
|
|
export const apollo = new ApolloClient({
|
2019-02-20 13:33:56 +00:00
|
|
|
link: authLink.concat(satelliteUrl),
|
|
|
|
cache: new InMemoryCache(),
|
|
|
|
connectToDevTools: true,
|
2018-12-18 14:43:23 +00:00
|
|
|
});
|