Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Latest commit

 

History

History
30 lines (23 loc) · 799 Bytes

README.md

File metadata and controls

30 lines (23 loc) · 799 Bytes

react-apollo-queries

Small <Query> wrapper component for react-apollo that supports multiple parallel queries and handles the nesting for you.

Instead of:

<Query query={LOAD_USER} variables={{ userId: this.props.userId }}>
  {({ data }) => <Query query={LOAD_IMAGES}}>
    ...
  </Query>}
</Query>

Write:

<Queries queries={[LOAD_USER, LOAD_IMAGES]} queriesProps={[
  {
    variables: { userId: this.props.userId}
  }
]}>
  {([ {data: userData }, {data: imagesData }]) => ...}
</Queries>

Motivation

When migrating to graphQL, and using something like apollo-link-rest, sometimes you want to throw parallel queries so faster fields don't have to wait on slower ones.