File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import { compose , withProps } from 'recompose' ;
2+ import { withApollo } from 'react-apollo' ;
3+
4+ export default function withFragment ( fragmentDocument , optionsObject ) {
5+ const name = ( optionsObject && optionsObject . name ) || 'data' ;
6+ return compose (
7+ withApollo ,
8+ withProps ( ( { client, ...rest } ) => {
9+ const fragment = client . readFragment ( {
10+ fragment : fragmentDocument ,
11+ id : optionsObject && optionsObject . getFragmentId ( rest ) ,
12+ } ) ;
13+
14+ return {
15+ [ name ] : fragment ,
16+ } ;
17+ } )
18+ ) ;
19+ }
Original file line number Diff line number Diff line change 1+ import { graphql } from 'react-apollo' ;
2+
3+ function RenderChild ( { data, children } ) {
4+ return children ( data ) ;
5+ }
6+
7+ export default function withQueryComponent ( queryDocument , optionsObject ) {
8+ const queryData = graphql ( queryDocument , optionsObject ) ;
9+ return queryData ( RenderChild ) ;
10+ }
You can’t perform that action at this time.
0 commit comments