Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Conversation

@jbaxleyiii
Copy link
Contributor

This makes including multiple graphql HOCs on a single component much easier. It uses the compose method from recompose.

// component
const Template = (props) => (<div></div>);

// old
import { graphql } from 'react-apollo';

const withPeople = graphql(peopleQuery, { name: 'people' });
const withShips = graphql(shipsQuery, { name: 'ships' });

const ContainerWithData = withPeople(withShips(Template));

// new
import { compose, graphql } from 'react-apollo';

const ContainerWithData = compose(
  graphql(peopleQuery, { name: 'people' }),
  graphql(shipsQuery, { name: 'ships' })
)(Template);

@zol zol added the in progress label Sep 6, 2016
@jbaxleyiii jbaxleyiii merged commit 4a9ffec into master Sep 6, 2016
@jbaxleyiii jbaxleyiii deleted the compose branch September 6, 2016 01:00
@zol zol removed the in progress label Sep 6, 2016
"lodash.isobject": "^3.0.2",
"object-assign": "^4.0.1"
"object-assign": "^4.0.1",
"recompose": "^0.20.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a big dependency? Doesn't redux also have a compose function we could use? Or are they different?

@sedubois
Copy link

sedubois commented Nov 9, 2016

Could this compose method be documented somewhere? It doesn't seem to be visible in http://dev.apollodata.com/react/.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants