···11+---
22+"@urql/exchange-throw-on-error": minor
33+---
44+55+Initial release
+15
exchanges/throw-on-error/README.md
···11+# @urql/exchange-throw-on-error (Exchange factory)
22+33+`@urql/exchange-throw-on-error` is an exchange for the [`urql`](../../README.md) GraphQL client that makes field access to data throw an error if the field errored.
44+55+It is built on top of the [`graphql-toe`](https://github.com/graphile/graphql-toe) package.
66+77+## Quick Start Guide
88+99+First install `@urql/exchange-throw-on-error` alongside `urql`:
1010+1111+```sh
1212+yarn add @urql/exchange-throw-on-error
1313+# or
1414+npm install --save @urql/exchange-throw-on-error
1515+```
···11+import type { Exchange } from '@urql/core';
22+import { mapExchange } from '@urql/core';
33+import { toe } from 'graphql-toe';
44+55+/** Exchange factory that maps the fields of the data to throw an error on access if the field was errored.
66+ *
77+ * @returns the created throw-on-error {@link Exchange}.
88+ */
99+export const throwOnErrorExchange = (): Exchange => {
1010+ return mapExchange({
1111+ onResult(result) {
1212+ if (result.data) {
1313+ const errors = result.error && result.error.graphQLErrors;
1414+ result.data = toe({ data: result.data, errors });
1515+ }
1616+ return result;
1717+ },
1818+ });
1919+};