storj/web/satellite/src/utils/apollo.ts

30 lines
783 B
TypeScript
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
import { InMemoryCache } from 'apollo-cache-inmemory';
2019-09-09 11:33:39 +01:00
import ApolloClient from 'apollo-client/ApolloClient';
import { setContext } from 'apollo-link-context';
2019-09-09 11:33:39 +01:00
import { HttpLink } from 'apollo-link-http';
// Satellite url
const satelliteUrl = new HttpLink({
uri: process.env.VUE_APP_ENDPOINT_URL,
});
// Adding additional headers
const authLink = setContext((_, {headers}) => {
// return the headers to the context so httpLink can read them
return {
headers: {
...headers,
},
};
});
// Creating apollo client
export const apollo = new ApolloClient({
link: authLink.concat(satelliteUrl),
cache: new InMemoryCache(),
connectToDevTools: true,
});