Recompose Apollo
a utility belt for higher-order components in apollo
. Recompose utilities for react-apollo
.
Higher-order components
withQueryData()
: HigherOrderComponent
Same functionality as react-apollo
graphql
HOC, except the data
prop or named data prop is flattened.
withQueryComponent()
: Component
Return a query component given a GraphQL document and options. What's returned is a Component
with a render child
that has the data object from react-apollo
, see below.
Query Components outlined: https://dev-blog.apollodata.com/query-components-with-apollo-ec603188c157
const CitiesQuery = ; { return <CitiesQuery> { return <p> I am loading dataloading ? 'Yes' : 'No' </p> ; } </CitiesQuery> ;}
withFragment()
: HigherOrderComponent
After a query has been made with the graphql
HOC, use this HOC to read fragments from the Apollo Client cache. Based on the options name
, the fragment data will be returned to the component as props under that key or data
.
withSubscribe()
: HigherOrderComponent
Create a GraphQL subscription that subscribes on componentDidMount
. By providing a
onResult
prop to the Component, every time the subscription yields next
, onResult
will be called with the result of the subscription.
withLoadingState()
: HigherOrderComponent
Render a Component if the networkStatus
from apollo-client
is loading, otherwise return props for networkStatus
:
activelyRefetching
passivelyRefetching
fetchingMore
withErrorState()
: HigherOrderComponent
Render a Component if the networkStatus
from apollo-client
is error
.