Skip to content

Instantly share code, notes, and snippets.

@marktani
Last active May 30, 2016 14:16
Show Gist options
  • Save marktani/5e309feb861509bda0a9432b9f6817ca to your computer and use it in GitHub Desktop.
Save marktani/5e309feb861509bda0a9432b9f6817ca to your computer and use it in GitHub Desktop.
import React from 'react'
import { render } from 'react-dom'
import TodoApp from './components/TodoApp'
import ApolloClient, { createNetworkInterface } from 'apollo-client'
import { registerGqlTag } from 'apollo-client/gql'
import { ApolloProvider } from 'react-apollo'
import { createStore, combineReducers, applyMiddleware } from 'redux'
import './style.css'
// Globally register gql template literal tag
registerGqlTag()
const networkInterface =
createNetworkInterface('https://api.graph.cool/simple/v1/__PROJECT_ID__')
const client = new ApolloClient({
networkInterface,
})
function filter (previousState = 'SHOW_ALL', action) {
if (action.type === 'SET_FILTER') {
return action.filter
}
return previousState
}
const store = createStore(
combineReducers({
filter,
apollo: client.reducer(),
}),
applyMiddleware(client.middleware()),
window.devToolsExtension ? window.devToolsExtension() : f => f
)
render(
<ApolloProvider store={store} client={client}>
<TodoApp />
</ApolloProvider>,
document.getElementById('root')
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment