File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,39 @@ withQueryData(
1515
1616Same functionality as ` react-apollo ` ` graphql ` HOC, except the ` data ` prop or named data prop is flattened.
1717
18+ ### ` withQueryComponent() `
19+
20+ ``` js
21+ withQueryComponent (
22+ queryDocument: DocumentNode,
23+ optionsObject: { options : (props ) => { variables } } | { options: Object }
24+ ): Component
25+ ```
26+
27+ Return a query component given a GraphQL document and options. What's returned is a Component
28+ with a render ` child ` that has the data object from ` react-apollo ` , see below.
29+
30+ Query Components outlined:
31+ https://dev-blog.apollodata.com/query-components-with-apollo-ec603188c157
32+
33+ ``` js
34+ const CitiesQuery = withQueryComponent (cityQuery);
35+
36+ function Sample () {
37+ return (
38+ < CitiesQuery>
39+ {
40+ (data ) => {
41+ return (
42+ < p> I am loading? {data .loading ? ' Yes' : ' No' }
43+ );
44+ }
45+ }
46+ < / CitiesQuery>
47+ );
48+ }
49+ ` ` `
50+
1851### ` withSubscribe ()`
1952
2053` ` ` js
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