apollo.js 878 B

1234567891011121314151617181920212223242526272829303132333435
  1. /**
  2. * Using next-with-apollo
  3. * https://github.com/lfades/next-with-apollo
  4. *
  5. * Changes:
  6. * * Reading endpoint and prodEndpoint from a config file
  7. * * Setting request to handle credentials.
  8. */
  9. // import { withData } from 'next-apollo'
  10. // import { HttpLink } from 'apollo-boost'
  11. import { ApolloLink } from 'apollo-link'
  12. import { onError } from 'apollo-link-error'
  13. import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
  14. import fetch from 'isomorphic-unfetch'
  15. const client = new ApolloClient({
  16. link: ApolloLink.from([
  17. onError(errors => {
  18. console.log(errors)
  19. if (errors && errors.response && errors.response.errors) {
  20. // errors.response.errors = null
  21. }
  22. }),
  23. new HttpLink({
  24. uri: 'http://localhost:8801/',
  25. credentials: 'include',
  26. fetch
  27. })
  28. ]),
  29. cache: new InMemoryCache()
  30. })
  31. export default client