Skip to content

Instantly share code, notes, and snippets.

@devtanc
Created July 17, 2019 21:34
Show Gist options
  • Save devtanc/0f099c035c027f0f44983cf9c190689f to your computer and use it in GitHub Desktop.
Save devtanc/0f099c035c027f0f44983cf9c190689f to your computer and use it in GitHub Desktop.
Apollo Client Query Wrapper Test
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