Skip to content

Instantly share code, notes, and snippets.

@RomanHotsiy
Last active May 25, 2017 16:07
Show Gist options
  • 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