1.0.2 • Published 6 years ago

apollo-error-overlay v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

apollo-error-overlay

Make apollo errors pretty and obvious

Apollo client passes network and graphql errors as props to you components, this is great for fine grained control, but when you are developing you often want a global error handler to catch errors quickly. Works with all apollo-client bindings (react, vue etc)

👀

demo

Usage

npm i apollo-error-overlay --save-dev
import { ApolloClient } from 'apollo-client'
import { HttpLink } from 'apollo-link-http'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { onError } from 'apollo-link-error'
import errorOverlay from 'apollo-error-overlay'

// setup errorLink
const errorLink = onError((errors) => {
  errorOverlay(errors)
  // do what ever else you want with the errors 
})

// setup httpLink
const httpLink = new HttpLink({
  uri: `http://localhost:80/graphql` 
})

// add links to the client
return new ApolloClient({
  link: errorLink.concat(httpLink),
  cache: new InMemoryCache()
})

Caveats

  • Hot reloads currently only work with webpacks hmr
1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago