@apollo-link-debug/handle-errors
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@apollo-link-debug/handle-errors

Debugs errors returned in a GraphQL response via apollo to the console.

Installation

npm i @apollo-link-debug/handle-errors
# - or -
yarn add @apollo-link-debug/handle-errors

Usage

import { ApolloClient, ApolloLink, InMemoryCache } from '@apollo/client';
import { createErrorsLink } from '@apollo-link-debug/handle-errors';

const client = new ApolloClient({
  uri: 'https://localhost:3000/',
  cache: new InMemoryCache(),
  link: ApolloLink.from([createErrorsLink()]),
});

Example output:

MyOperationName GraphQL error
  on line: 1, column: 6

Options

onGraphQLErrors: ({ operation, errors, message }) => void

A callback which occurs when an error is returned from the GraphQL request. The errors object is an array of errors returned from the server, and the message is a string with a human-readable intepretation of the error.

onNetworkError: ({ operation, error }) => void

A callback which occurs when there is an error outside of the GraphQL sphere. For example, the server may not be contactable.

Readme

Keywords

none

Package Sidebar

Install

npm i @apollo-link-debug/handle-errors

Weekly Downloads

77

Version

0.0.5

License

MIT

Unpacked Size

5.67 kB

Total Files

10

Last publish

Collaborators

  • bashaus