mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Update Apollo example (#1021)
* Add minimal apollo example * Update apollo example README * Update apollo example demo link in README * Fix button styles * Fix show more button * Alias demo url * Include the data field on the Apollo store when hydrating * Revert * Include the data field on the Apollo store when hydrating per tpreusse's suggestion. * Add example to faq section in README * Sort by newest; Add active state to buttons * Make optimization suggestions * Use process.browser; inline props * Pass wrapped component's initial props into component heirarchy if they exist * Remove unnecessary sorting of array * Update Apollo example * Remove trailing comma * Update reduxRootKey * Remove unnecessary babelrc
This commit is contained in:
parent
8dfbbd3674
commit
01cc898450
|
@ -5,12 +5,12 @@ let apolloClient = null
|
||||||
function createClient (headers) {
|
function createClient (headers) {
|
||||||
return new ApolloClient({
|
return new ApolloClient({
|
||||||
ssrMode: !process.browser,
|
ssrMode: !process.browser,
|
||||||
headers,
|
|
||||||
dataIdFromObject: result => result.id || null,
|
dataIdFromObject: result => result.id || null,
|
||||||
networkInterface: createNetworkInterface({
|
networkInterface: createNetworkInterface({
|
||||||
uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn',
|
uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn',
|
||||||
opts: {
|
opts: {
|
||||||
credentials: 'same-origin'
|
credentials: 'same-origin'
|
||||||
|
// Pass headers here if your graphql server requires them
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,8 +29,8 @@ export default (Component) => (
|
||||||
return {
|
return {
|
||||||
initialState: {
|
initialState: {
|
||||||
...state,
|
...state,
|
||||||
apollo: {
|
[client.reduxRootKey]: {
|
||||||
data: state.apollo.data
|
data: client.getInitialState().data
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
headers,
|
headers,
|
||||||
|
|
Loading…
Reference in a new issue