Last active
May 17, 2016 22:39
-
-
Save stubailo/6181e37b0fa157506223eac0792a6b27 to your computer and use it in GitHub Desktop.
Apollo client code snippets for React+Redux post
This file contains 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
// 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