Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions examples/with-apollo-and-redux/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/with-apollo-and-redux)
# Apollo & Redux Example

Note: This example uses an older version of Apollo Client (version 1.0)

## How to use

Download the example [or clone the repo](https://github.com/zeit/next.js):
Expand All @@ -24,7 +26,7 @@ now
```

## The idea behind the example
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](http://dev.apollodata.com/react/redux.html), which is what this example does. This example is identical to the [`with-apollo`](https://github.com/zeit/next.js/tree/master/examples/with-apollo) with the exception of this Redux store integration.
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](http://dev.apollodata.com/react/redux.html), which is what this example does. This example is identical to the [`with-apollo`](https://github.com/zeit/next.js/tree/master/examples/with-apollo) with the exception of this Redux store integration.

Note that you can acesss the redux store like you normally would using `react-redux`'s `connect` as per [here](http://dev.apollodata.com/react/redux.html#using-connect). Here's a quick example:

Expand All @@ -36,5 +38,4 @@ const mapStateToProps = state => ({
export default withData(connect(mapStateToProps, null)(Index));
```

`connect` must go inside `withData` otherwise `connect` will not be able to find the store.

`connect` must go inside `withData` otherwise `connect` will not be able to find the store.
2 changes: 2 additions & 0 deletions examples/with-apollo-auth/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Deploy to now](https://deploy.now.sh/static/button.svg)](https://deploy.now.sh/?repo=https://github.com/zeit/next.js/tree/master/examples/with-apollo-auth)
# Apollo With Authentication Example

Note: This example uses an older version of Apollo Client (version 1.0)

## Demo

https://next-with-apollo-auth.now.sh
Expand Down
13 changes: 13 additions & 0 deletions examples/with-apollo/lib/apollo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { withData } from 'next-apollo'
import { HttpLink } from 'apollo-link-http'

const config = {
link: new HttpLink({
uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn', // Server URL (must be absolute)
opts: {
credentials: 'same-origin' // Additional fetch() options like `credentials` or `headers`
}
})
}

export default withData(config)
40 changes: 0 additions & 40 deletions examples/with-apollo/lib/initApollo.js

This file was deleted.

77 changes: 0 additions & 77 deletions examples/with-apollo/lib/withData.js

This file was deleted.

1 change: 1 addition & 0 deletions examples/with-apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"graphql-tag": "^2.5.0",
"isomorphic-fetch": "^2.2.1",
"next": "latest",
"next-apollo": "^1.0.4",
"prop-types": "^15.5.8",
"react": "^16.0.0",
"react-apollo": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/with-apollo/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import App from '../components/App'
import Header from '../components/Header'
import Submit from '../components/Submit'
import PostList from '../components/PostList'
import withData from '../lib/withData'
import withData from '../lib/apollo'

export default withData((props) => (
export default withData(props => (
<App>
<Header pathname={props.url.pathname} />
<Submit />
Expand Down