Created
July 17, 2019 21:34
-
-
Save devtanc/0f099c035c027f0f44983cf9c190689f to your computer and use it in GitHub Desktop.
Apollo Client Query Wrapper Test
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 { graphql } from 'react-apollo'; | |
import { get } from 'lodash'; | |
export default ({ query, options = () => {}, props = {}, skip = false }) => | |
graphql(query, { | |
options: parentProps => ({ | |
fetchPolicy: 'cache-and-network', | |
...options(parentProps), | |
}), | |
props, | |
skip, | |
alias: `withQuery(${get(query, 'definitions[0].name.value') || null})`, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment