Last active
October 25, 2016 07:42
-
-
Save Horusiath/f092917a8e6d3a3bc6d7554a1cb11bc2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withCommunities = graphql(gql` | |
query CommunitiesQuery($offset: Int!, $limit: Int!) { | |
viewer { | |
communities(offset: $offset, limit: $limit) { | |
totalCount, | |
elements { | |
id | |
...communityInfo | |
} | |
} | |
} | |
} | |
`, { | |
props({data}) { | |
// this part is called with a data.viewer being undefined | |
return { communities: data.viewer.communities }; | |
}, | |
options(props) { | |
return { | |
forceFetch: true, | |
fragments: Community.fragment, | |
variables: { | |
offset: 0, | |
limit: Pager.PAGE_SIZE | |
} | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { Router, Route, IndexRoute, Link, hashHistory } from 'react-router'; | |
import createHistory from 'history/createHashHistory'; | |
import ApolloClient, { createNetworkInterface } from 'apollo-client'; | |
import { ApolloProvider } from 'react-apollo'; | |
import { createStore, combineReducers, applyMiddleware, compose } from 'redux'; | |
const client = new ApolloClient({ | |
networkInterface: createNetworkInterface("http://localhost:8083/") | |
}); | |
let combinedReducer = combineReducers({ | |
filter: 'SHOW_ALL', | |
apollo: client.reducer() | |
}); | |
const store = compose( | |
applyMiddleware( | |
client.middleware() | |
) | |
)(createStore)(combinedReducer); | |
ReactDOM.render( | |
<ApolloProvider client={client} store={store}> | |
<Router history={hashHistory}> | |
{ routes } | |
</Router> | |
</ApolloProvider>, | |
document.getElementById('container') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment