Skip to content

Instantly share code, notes, and snippets.

@RomanHotsiy
Last active May 25, 2017 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RomanHotsiy/c0fe09fdc86f2466aaa852ffc5d55652 to your computer and use it in GitHub Desktop.
Save RomanHotsiy/c0fe09fdc86f2466aaa852ffc5d55652 to your computer and use it in GitHub Desktop.
import { graphql } from 'react-apollo';
import { graphqlLodash } from 'graphql-lodash';
export function gqlLodash(rawQuery, config) {
const {query, transform} = graphqlLodash(rawQuery);
// save original props callback
let origProps = (config && config.props) || ((props) => props);
return (comp) => graphql(query, {...config,
props: (props) => origProps({
...props,
rawData: props.data,
data: transform(props.data)
})
})(comp);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment