Skip to content

Instantly share code, notes, and snippets.

@Horusiath
Last active October 25, 2016 07:42
Show Gist options
  • Save Horusiath/f092917a8e6d3a3bc6d7554a1cb11bc2 to your computer and use it in GitHub Desktop.
Save Horusiath/f092917a8e6d3a3bc6d7554a1cb11bc2 to your computer and use it in GitHub Desktop.
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
}
}
}
});
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