Revert "Add graph-handling for different environments"

This reverts commit 1ad951ca60.
This commit is contained in:
2019-01-15 20:03:45 +01:00
parent 1ad951ca60
commit e42467de88
3 changed files with 2 additions and 42 deletions
+2 -28
View File
@@ -1,36 +1,10 @@
const queryString = require('query-string');
const { createApolloFetch } = require('apollo-fetch');
const { includeCredentials } = require('./middleware');
const defaultGraphUri = 'https://dancefinder.unbound.se/graph';
const getGraphURI = () => {
let graphUri = defaultGraphUri;
try {
const loc = location; // eslint-disable-line
const search = (loc && loc.search) || '';
const host = (loc && loc.host) || '';
const query = queryString.parse(search);
const isLocal = host.includes('localhost');
if (query.graph) {
// if a query param is provided - always use that.
graphUri = query.graph;
} else if (isLocal) {
// If a query param is not provided - check if we're running locally or on heroku,
// and if so default to /graphql for mocking purposes
graphUri = '/graph';
}
} catch (err) {
// just suppress this madness
}
return graphUri;
};
const defaultGraphUri = '/graph';
export const createQuery = (tokenFn, query, variables) => { // eslint-disable-line
const apollo = createApolloFetch({ uri: getGraphURI() });
const apollo = createApolloFetch({ uri: defaultGraphUri });
apollo.use(includeCredentials(tokenFn));
// apollo.useAfter(trackErrors);