Use Redux with Apollo Client

  • Angular
    • If you want to use your own store, you’ll need to pass in reducer and middleware from your Apollo Client instance into NgRedux.
    • this guide focuses on the integration with ng2-redux. An integration with ngrx/store is theoretically possible though too.
  • React
    • Apollo Client uses Redux internally, and you can integrate it into your existing store to use your favorite Redux tools such as the dev tools or persistence libraries. You can also use Apollo alongside any other data management library, such as MobX.
    • With Recompose, React-Apollo’s Higher Order Component can be combined with a variety of other utilities to add behaviors to your components. Read how to use it for loading state and variables and also mutations and to combine with the Redux container.
    • If you want to use your own store, you’ll need to pass in reducer and middleware from your Apollo Client instance; you can then pass the store into your ApolloProvider directly. ref http://dev.apollodata.com/react/redux.html
    • By default, Apollo Client creates its own internal Redux store to manage queries and their results. If you are already using Redux for the rest of your app, you can have the client integrate with your existing store instead.

      Note: While this will enable Apollo Client to keep its data in the same store, you should still use the graphql container to attach the data to your UI. If you want to use your Redux and Apollo state in a component, you need to use both graphql from react-apollo and connect from react-redux.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s