This commit is contained in:
Sergey Yarkov 2020-03-16 21:26:13 +03:00
commit c4add51ac1
7 changed files with 1147 additions and 5 deletions

6
.gitignore vendored
View File

@ -23,3 +23,9 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
<<<<<<< HEAD
=======
# cms
cms
>>>>>>> d845bf167260c295393e750017fc4e327e987967

View File

@ -68,6 +68,9 @@ export default withData(Articles)
```
## License:
[MIT](https://github.com/sergeyyarkov/next-apollo-graphql-setup/blob/master/LICENSE)
### This is a next-strapi-mongo setup to start develop your web site. This setup uses server side rendering.

18
apolloClient.js Normal file
View File

@ -0,0 +1,18 @@
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'
import fetch from 'isomorphic-unfetch'
export default function createApolloClient (initialState, ctx) {
// The `ctx` (NextPageContext) will only be present on the server.
// use it to extract auth headers (ctx.req) or similar.
return new ApolloClient({
ssrMode: Boolean(ctx),
link: new HttpLink({
uri: 'https://next-blog-example.herokuapp.com/graphql', // Server URL (must be absolute)
credentials: 'same-origin', // Additional fetch() options like `credentials` or `headers`
fetch
}),
cache: new InMemoryCache().restore(initialState)
})
}

View File

@ -15,6 +15,4 @@ server {
location = /50x.html {
root /usr/share/nginx/html;
}
}

1113
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -31,4 +31,8 @@ const Articles = () => {
)
}
<<<<<<< HEAD
export default withApollo(Articles)
=======
export default withApollo({ ssr: true })(Articles)
>>>>>>> d845bf167260c295393e750017fc4e327e987967