Skip to content

Instantly share code, notes, and snippets.

@stubailo
Last active May 17, 2016 22:39
Show Gist options
  • Save stubailo/6181e37b0fa157506223eac0792a6b27 to your computer and use it in GitHub Desktop.
Save stubailo/6181e37b0fa157506223eac0792a6b27 to your computer and use it in GitHub Desktop.
Apollo client code snippets for React+Redux post
// Works just like `react-redux` connect
import { connect } from 'react-apollo';
import Category from './category';
function mapQueriesToProps({ ownProps, state }) {
return {
category: {
query: gql`
query getCategory($categoryId: Int!) {
category(id: $categoryId) {
name
color
}
}
`,
variables: {
categoryId: 5,
},
},
};
};
const CategoryWithData = connect({
mapQueriesToProps,
})(Category);
export default CategoryWithData;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment