Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
1# @urql/exchange-throw-on-error (Exchange factory)
2
3`@urql/exchange-throw-on-error` is an exchange for the [`urql`](https://github.com/urql-graphql/urql) GraphQL client that throws on field access to errored fields.
4
5It is built on top of the [`graphql-toe`](https://github.com/graphile/graphql-toe) package - please see that package for more information.
6
7## Quick Start Guide
8
9First install `@urql/exchange-throw-on-error` alongside `urql`:
10
11```sh
12yarn add @urql/exchange-throw-on-error
13# or
14npm install --save @urql/exchange-throw-on-error
15```
16
17Then add the `throwOnErrorExchange`, to your client:
18
19```js
20import { createClient, cacheExchange, fetchExchange } from 'urql';
21import { throwOnErrorExchange } from '@urql/exchange-throw-on-error';
22
23const client = createClient({
24 url: '/graphql',
25 exchanges: [cacheExchange, throwOnErrorExchange(), fetchExchange],
26});
27```