2016-10-19 10:55:19 +02:00
|
|
|
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
|
|
|
|
import ApolloClient from 'apollo-client';
|
|
|
|
|
2016-10-19 10:32:24 +02:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-10-19 10:55:19 +02:00
|
|
|
import { meteorClientConfig } from 'meteor/apollo';
|
2016-10-19 10:32:24 +02:00
|
|
|
|
2016-10-19 10:55:19 +02:00
|
|
|
// see https://github.com/apollostack/meteor-integration/blob/master/package.js#L15
|
|
|
|
// on one hand, a client-side function shouldn't exist server-side
|
|
|
|
// on the other hand, it breaks server-side rendering
|
|
|
|
const config = Meteor.isClient ? meteorClientConfig() : {}; // so, that feels weird.
|
2016-10-19 10:32:24 +02:00
|
|
|
|
2016-10-19 10:55:19 +02:00
|
|
|
const client = new ApolloClient(config);
|
2016-10-19 10:32:24 +02:00
|
|
|
|
2016-10-19 10:55:19 +02:00
|
|
|
const rootReducer = combineReducers({...Telescope.reducers, apollo: client.reducer()});
|
2016-10-19 10:32:24 +02:00
|
|
|
|
2016-10-19 10:55:19 +02:00
|
|
|
const store = createStore(
|
|
|
|
// reducers
|
|
|
|
rootReducer,
|
|
|
|
// middlewares
|
|
|
|
compose(
|
|
|
|
applyMiddleware(client.middleware()),
|
|
|
|
typeof window !== "undefined" && window.devToolsExtension ? window.devToolsExtension() : f => f
|
|
|
|
),
|
|
|
|
);
|
2016-10-19 10:32:24 +02:00
|
|
|
|
2016-10-19 10:55:19 +02:00
|
|
|
export { store, client };
|